• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 interface CaptureAsInferredTypeArgument {
22   interface Lib<T extends @Nullable Object> {}
23 
useImplicitlyObjectBounded(Lib<T> l)24   <T> void useImplicitlyObjectBounded(Lib<T> l);
25 
useExplicitlyObjectBounded(Lib<T> l)26   <T extends Object> void useExplicitlyObjectBounded(Lib<T> l);
27 
useUnspecBounded(Lib<T> l)28   <T extends @NullnessUnspecified Object> void useUnspecBounded(Lib<T> l);
29 
useUnionNullBounded(Lib<T> l)30   <T extends @Nullable Object> void useUnionNullBounded(Lib<T> l);
31 
objectBounded(Lib<? extends Object> l)32   default void objectBounded(Lib<? extends Object> l) {
33     useImplicitlyObjectBounded(l);
34     useExplicitlyObjectBounded(l);
35     useUnspecBounded(l);
36     useUnionNullBounded(l);
37   }
38 
unspecBounded(Lib<? extends @NullnessUnspecified Object> l)39   default void unspecBounded(Lib<? extends @NullnessUnspecified Object> l) {
40     // jspecify_nullness_not_enough_information
41     useImplicitlyObjectBounded(l);
42     // jspecify_nullness_not_enough_information
43     useExplicitlyObjectBounded(l);
44     // jspecify_nullness_not_enough_information
45     useUnspecBounded(l);
46     useUnionNullBounded(l);
47   }
48 
implicitlyUnionNullBounded(Lib<?> l)49   default void implicitlyUnionNullBounded(Lib<?> l) {
50     // jspecify_nullness_mismatch
51     useImplicitlyObjectBounded(l);
52     // jspecify_nullness_mismatch
53     useExplicitlyObjectBounded(l);
54     // jspecify_nullness_not_enough_information
55     useUnspecBounded(l);
56     useUnionNullBounded(l);
57   }
58 
explicitlyUnionNullBounded(Lib<? extends @Nullable Object> l)59   default void explicitlyUnionNullBounded(Lib<? extends @Nullable Object> l) {
60     // jspecify_nullness_mismatch
61     useImplicitlyObjectBounded(l);
62     // jspecify_nullness_mismatch
63     useExplicitlyObjectBounded(l);
64     // jspecify_nullness_not_enough_information
65     useUnspecBounded(l);
66     useUnionNullBounded(l);
67   }
68 }
69