mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Java: Add test for multiply-bounded wildcards
This exercises several cases of variables bounded both by a wildcard and by a bound on the type parameter, checking that the extractor strips the wildcards and captures to decide on a concrete type for the parameters and return values.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
public class Test {
|
||||
|
||||
static class BoundedGeneric<T extends CharSequence> {
|
||||
public T getter(int unused) { return null; }
|
||||
public void setter(T t) { }
|
||||
}
|
||||
|
||||
public static BoundedGeneric<?> getUnbounded() { return null; }
|
||||
|
||||
public static BoundedGeneric<? super String> getLowerBounded() { return null; }
|
||||
|
||||
public static void test() {
|
||||
CharSequence cs = getUnbounded().getter(0);
|
||||
Object o = getLowerBounded().getter(0);
|
||||
getUnbounded().setter(null);
|
||||
getLowerBounded().setter(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
| Test$BoundedGeneric.class:0:0:0:0 | getter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<? super String> | CharSequence | int |
|
||||
| Test$BoundedGeneric.class:0:0:0:0 | getter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<?> | CharSequence | int |
|
||||
| Test$BoundedGeneric.class:0:0:0:0 | setter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<? super String> | void | String |
|
||||
| Test$BoundedGeneric.class:0:0:0:0 | setter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<?> | void | <nulltype> |
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma
|
||||
select ma.getCallee(), ma.getCallee().getDeclaringType(), ma.getCallee().getReturnType().toString(),
|
||||
ma.getCallee().getAParamType().toString()
|
||||
Reference in New Issue
Block a user