Debian Codegraph @

checker/tests/nullness/generics/Issue337.java

raw
1 // Test case for Issue 337:
2 // https://github.com/typetools/checker-framework/issues/337
3
4 import javax.annotation.Nullable;
5
6 abstract class Issue337<R> {
7 abstract R getThing(String key);
8
9 @Nullable R m1(@Nullable String key) {
10 return (key == null) ? null : getThing(key);
11 }
12
13 @Nullable R m1b(@Nullable String key) {
14 return (key != null) ? getThing(key) : null;
15 }
16
17 @Nullable R m2(@Nullable String key) {
18 return (key == null)
19 ?
20 // :: error: (argument.type.incompatible)
21 getThing(key)
22 : null;
23 }
24
25 @Nullable R m2b(@Nullable String key) {
26 return (key != null)
27 ? null
28 :
29 // :: error: (argument.type.incompatible)
30 getThing(key);
31 }
32 }