Skip to content

Commit d999c1d

Browse files
committed
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.
1 parent 1cd3084 commit d999c1d

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Test {
2+
3+
static class BoundedGeneric<T extends CharSequence> {
4+
public T getter(int unused) { return null; }
5+
public void setter(T t) { }
6+
}
7+
8+
public static BoundedGeneric<?> getUnbounded() { return null; }
9+
10+
public static BoundedGeneric<? super String> getLowerBounded() { return null; }
11+
12+
public static void test() {
13+
CharSequence cs = getUnbounded().getter(0);
14+
Object o = getLowerBounded().getter(0);
15+
getUnbounded().setter(null);
16+
getLowerBounded().setter(null);
17+
}
18+
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| Test$BoundedGeneric.class:0:0:0:0 | getter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<? super String> | CharSequence | int |
2+
| Test$BoundedGeneric.class:0:0:0:0 | getter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<?> | CharSequence | int |
3+
| Test$BoundedGeneric.class:0:0:0:0 | setter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<? super String> | void | String |
4+
| Test$BoundedGeneric.class:0:0:0:0 | setter | Test$BoundedGeneric.class:0:0:0:0 | BoundedGeneric<?> | void | <nulltype> |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import java
2+
3+
from MethodAccess ma
4+
select ma.getCallee(), ma.getCallee().getDeclaringType(), ma.getCallee().getReturnType().toString(),
5+
ma.getCallee().getAParamType().toString()

0 commit comments

Comments
 (0)