• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SuperTypeVariable {
implicitlyObjectBounded( Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull)22   <T> void implicitlyObjectBounded(
23       Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull) {
24     lib.useT(t);
25 
26     // jspecify_nullness_not_enough_information
27     lib.useT(tUnspec);
28 
29     // jspecify_nullness_mismatch
30     lib.useT(tUnionNull);
31 
32     //
33 
34     lib.useTUnspec(t);
35 
36     // jspecify_nullness_not_enough_information
37     lib.useTUnspec(tUnspec);
38 
39     // jspecify_nullness_not_enough_information
40     lib.useTUnspec(tUnionNull);
41 
42     //
43 
44     lib.useTUnionNull(t);
45 
46     lib.useTUnionNull(tUnspec);
47 
48     lib.useTUnionNull(tUnionNull);
49   }
50 
explicitlyObjectBounded( Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull)51   <T extends Object> void explicitlyObjectBounded(
52       Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull) {
53     lib.useT(t);
54 
55     // jspecify_nullness_not_enough_information
56     lib.useT(tUnspec);
57 
58     // jspecify_nullness_mismatch
59     lib.useT(tUnionNull);
60 
61     //
62 
63     lib.useTUnspec(t);
64 
65     // jspecify_nullness_not_enough_information
66     lib.useTUnspec(tUnspec);
67 
68     // jspecify_nullness_not_enough_information
69     lib.useTUnspec(tUnionNull);
70 
71     //
72 
73     lib.useTUnionNull(t);
74 
75     lib.useTUnionNull(tUnspec);
76 
77     lib.useTUnionNull(tUnionNull);
78   }
79 
unspecBounded( Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull)80   <T extends @NullnessUnspecified Object> void unspecBounded(
81       Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull) {
82     lib.useT(t);
83 
84     // jspecify_nullness_not_enough_information
85     lib.useT(tUnspec);
86 
87     // jspecify_nullness_mismatch
88     lib.useT(tUnionNull);
89 
90     //
91 
92     lib.useTUnspec(t);
93 
94     // jspecify_nullness_not_enough_information
95     lib.useTUnspec(tUnspec);
96 
97     // jspecify_nullness_not_enough_information
98     lib.useTUnspec(tUnionNull);
99 
100     //
101 
102     lib.useTUnionNull(t);
103 
104     lib.useTUnionNull(tUnspec);
105 
106     lib.useTUnionNull(tUnionNull);
107   }
108 
nullableBounded( Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull)109   <T extends @Nullable Object> void nullableBounded(
110       Lib<? super T> lib, T t, @NullnessUnspecified T tUnspec, @Nullable T tUnionNull) {
111     lib.useT(t);
112 
113     // jspecify_nullness_not_enough_information
114     lib.useT(tUnspec);
115 
116     // jspecify_nullness_mismatch
117     lib.useT(tUnionNull);
118 
119     //
120 
121     lib.useTUnspec(t);
122 
123     // jspecify_nullness_not_enough_information
124     lib.useTUnspec(tUnspec);
125 
126     // jspecify_nullness_not_enough_information
127     lib.useTUnspec(tUnionNull);
128 
129     //
130 
131     lib.useTUnionNull(t);
132 
133     lib.useTUnionNull(tUnspec);
134 
135     lib.useTUnionNull(tUnionNull);
136   }
137 
138   interface Lib<T extends @Nullable Object> {
useT(T t)139     void useT(T t);
140 
useTUnspec(@ullnessUnspecified T t)141     void useTUnspec(@NullnessUnspecified T t);
142 
useTUnionNull(@ullable T t)143     void useTUnionNull(@Nullable T t);
144   }
145 }
146