Debian Codegraph @

samples/NotNullMarkedUseOfTypeVariable.java

raw
1 /*
2 * Copyright 2020 The JSpecify Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 import org.jspecify.annotations.NullMarked;
17 import org.jspecify.annotations.Nullable;
18 import org.jspecify.annotations.NullnessUnspecified;
19
20 class NotNullMarkedUseOfTypeVariable {
21 interface Super<T extends @Nullable Object> {
22 T get();
23 }
24
25 @NullMarked
26 interface SubObject extends Super<Object> {}
27
28 @NullMarked
29 interface SubObjectUnspec extends Super<@NullnessUnspecified Object> {}
30
31 @NullMarked
32 interface SubObjectUnionNull extends Super<@Nullable Object> {}
33
34 @NullMarked
35 class Caller {
36 Object x0(SubObject s) {
37 // jspecify_nullness_not_enough_information
38 return s.get();
39 }
40
41 Object x1(SubObjectUnspec s) {
42 // jspecify_nullness_not_enough_information
43 return s.get();
44 }
45
46 Object x2(SubObjectUnionNull s) {
47 // jspecify_nullness_mismatch
48 return s.get();
49 }
50
51 Object x3(Super<Object> s) {
52 // jspecify_nullness_not_enough_information
53 return s.get();
54 }
55
56 Object x4(Super<@NullnessUnspecified Object> s) {
57 // jspecify_nullness_not_enough_information
58 return s.get();
59 }
60
61 Object x5(Super<@Nullable Object> s) {
62 // jspecify_nullness_mismatch
63 return s.get();
64 }
65
66 Object x6(Super<? extends Object> s) {
67 // jspecify_nullness_not_enough_information
68 return s.get();
69 }
70
71 Object x7(Super<? extends @NullnessUnspecified Object> s) {
72 // jspecify_nullness_not_enough_information
73 return s.get();
74 }
75
76 Object x8(Super<? extends @Nullable Object> s) {
77 // jspecify_nullness_mismatch
78 return s.get();
79 }
80
81 Object x9(Super<?> s) {
82 // jspecify_nullness_mismatch
83 return s.get();
84 }
85 }
86 }