Debian Codegraph @

samples/NotNullMarkedUseOfTypeVariableAsTypeArgument.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 NotNullMarkedUseOfTypeVariableAsTypeArgument {
21 @NullMarked
22 interface Lib<T extends @Nullable Object> {}
23
24 interface Super<T extends @Nullable Object> {
25 Lib<T> get();
26 }
27
28 @NullMarked
29 interface SubObject extends Super<Object> {}
30
31 @NullMarked
32 interface SubObjectUnspec extends Super<@NullnessUnspecified Object> {}
33
34 @NullMarked
35 interface SubObjectUnionNull extends Super<@Nullable Object> {}
36
37 @NullMarked
38 class Caller {
39 @Nullable Lib<? extends Object> x0(SubObject s) {
40 // jspecify_nullness_not_enough_information
41 return s.get();
42 }
43
44 @Nullable Lib<? extends Object> x1(SubObjectUnspec s) {
45 // jspecify_nullness_not_enough_information
46 return s.get();
47 }
48
49 @Nullable Lib<? extends Object> x2(SubObjectUnionNull s) {
50 // jspecify_nullness_mismatch
51 return s.get();
52 }
53
54 @Nullable Lib<? extends Object> x3(Super<Object> s) {
55 // jspecify_nullness_not_enough_information
56 return s.get();
57 }
58
59 @Nullable Lib<? extends Object> x4(Super<@NullnessUnspecified Object> s) {
60 // jspecify_nullness_not_enough_information
61 return s.get();
62 }
63
64 @Nullable Lib<? extends Object> x5(Super<@Nullable Object> s) {
65 // jspecify_nullness_mismatch
66 return s.get();
67 }
68
69 @Nullable Lib<? extends Object> x6(Super<? extends Object> s) {
70 // jspecify_nullness_not_enough_information
71 return s.get();
72 }
73
74 @Nullable Lib<? extends Object> x7(Super<? extends @NullnessUnspecified Object> s) {
75 // jspecify_nullness_not_enough_information
76 return s.get();
77 }
78
79 @Nullable Lib<? extends Object> x8(Super<? extends @Nullable Object> s) {
80 // jspecify_nullness_mismatch
81 return s.get();
82 }
83
84 @Nullable Lib<? extends Object> x9(Super<?> s) {
85 // jspecify_nullness_mismatch
86 return s.get();
87 }
88 }
89 }