Debian Codegraph @

framework/tests/all-systems/Issue2302.java

raw
1 // Test case for Issue 2302
2 // https://github.com/typetools/checker-framework/issues/2302
3
4 @SuppressWarnings("unchecked")
5 class Issue2302 {
6 static class StrangeConstructorTypeArgs<V> {
7 // The constructor does not use the type parameter V.
8 public StrangeConstructorTypeArgs(MyClass<byte[]> abs) {}
9 }
10
11 static class MyClass<VALUE> {}
12
13 static StrangeConstructorTypeArgs getStrangeConstructorTypeArgs() {
14 // Crash with the diamond operator.
15 // Type inference chooses `Object` as the type argument.
16 // That is a bug, since it should choose exactly `byte[]`.
17 return new StrangeConstructorTypeArgs(new MyClass<>());
18
19 // No crash with an explicit type argument (no diamond operator), no matter what it is.
20 // return new StrangeConstructorTypeArgs(new MyClass<byte[]>());
21 // return new StrangeConstructorTypeArgs(new MyClass<Integer>());
22 // return new StrangeConstructorTypeArgs(new MyClass<Object>());
23 // return new StrangeConstructorTypeArgs(new MyClass<@Tainted Object>());
24 }
25 }