Debian Codegraph @

samples/MultiplePathsToTypeVariable.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 @NullMarked
21 class MultiplePathsToTypeVariable {
22 interface TBounded<T, U extends T> {
23 U get();
24 }
25
26 interface TUnspecBounded<T, U extends @NullnessUnspecified T> {
27 U get();
28 }
29
30 interface TUnionNullBounded<T, U extends @Nullable T> {
31 U get();
32 }
33
34 <T> Object x0(TBounded<T, ? extends T> t) {
35 return t.get();
36 }
37
38 <T> Object x1(TBounded<T, ? extends @NullnessUnspecified T> t) {
39 return t.get();
40 }
41
42 <T> Object x2(TBounded<T, ? extends @Nullable T> t) {
43 return t.get();
44 }
45
46 <T> Object x3(TUnspecBounded<T, ? extends T> t) {
47 return t.get();
48 }
49
50 <T> Object x4(TUnspecBounded<T, ? extends @NullnessUnspecified T> t) {
51 // jspecify_nullness_not_enough_information
52 return t.get();
53 }
54
55 <T> Object x5(TUnspecBounded<T, ? extends @Nullable T> t) {
56 // jspecify_nullness_not_enough_information
57 return t.get();
58 }
59
60 <T> Object x6(TUnionNullBounded<T, ? extends T> t) {
61 return t.get();
62 }
63
64 <T> Object x7(TUnionNullBounded<T, ? extends @NullnessUnspecified T> t) {
65 // jspecify_nullness_not_enough_information
66 return t.get();
67 }
68
69 <T> Object x8(TUnionNullBounded<T, ? extends @Nullable T> t) {
70 // jspecify_nullness_mismatch
71 return t.get();
72 }
73 }