mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #11079 from smowton/smowton/test/test-java-extractor-vs-captured-type-variables
Java: Add test for multiply-bounded wildcards
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()
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.Collection;
|
||||
|
||||
public class Test {
|
||||
|
||||
public Collection<? extends CharSequence> getCollection() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
this.getCollection().isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from Method m, Type t
|
||||
where m.getAParamType() = t and t.toString().matches("%? super ? extends%")
|
||||
select m, t
|
||||
Reference in New Issue
Block a user