Debian Codegraph @

samples/NotNullMarkedTypeVariableBound.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 NotNullMarkedTypeVariableBound {
21 class UnspecBounded1<T> {
22 @NullMarked
23 abstract class Nested {
24 abstract T get();
25 }
26 }
27
28 class UnspecBounded2<T extends Object> {
29 @NullMarked
30 abstract class Nested {
31 abstract T get();
32 }
33 }
34
35 class UnspecBounded3<T extends @NullnessUnspecified Object> {
36 @NullMarked
37 abstract class Nested {
38 abstract T get();
39 }
40 }
41
42 class NullBounded<T extends @Nullable Object> {
43 @NullMarked
44 abstract class Nested {
45 abstract T get();
46 }
47 }
48
49 @NullMarked
50 class Callers {
51 Object x0(UnspecBounded1<?>.Nested x) {
52 // jspecify_nullness_not_enough_information
53 return x.get();
54 }
55
56 Object x0(UnspecBounded2<?>.Nested x) {
57 // jspecify_nullness_not_enough_information
58 return x.get();
59 }
60
61 Object x0(UnspecBounded3<?>.Nested x) {
62 // jspecify_nullness_not_enough_information
63 return x.get();
64 }
65
66 Object x0(NullBounded<?>.Nested x) {
67 // jspecify_nullness_mismatch
68 return x.get();
69 }
70 }
71 }