Debian Codegraph @

checker/tests/nullness/java8inference/Issue2235.java

raw
1 // Test case that was submitted in Issue 2235, but is caused
2 // by a false negative from Issue 979
3 // https://github.com/typetools/checker-framework/issues/979
4
5 // Skip until correct error is issued.
6 // @skip-test
7
8 public class Issue2235 {
9 // Simple wrapper class with a public generic method
10 // to make an instance:
11 static class Holder<T> {
12 T t;
13
14 private Holder(T t) {
15 this.t = t;
16 }
17
18 public static <T> Holder<T> make(T t) {
19 return new Holder<>(t);
20 }
21 }
22
23 public static void main(String[] args) throws Exception {
24 // Null is hidden via nested calls, but assigned to a non-null type:
25 // :: error: (TODO)
26 Holder<Holder<String>> h = Holder.make(Holder.make(null));
27 // NullPointerException will fire here:
28 h.t.t.toString();
29 }
30 }