• 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 abstract class ArraySameType {
22   interface Lib<T> {}
23 
useArray(Lib<Object[]> l)24   abstract void useArray(Lib<Object[]> l);
25 
useArrayOfUnspec(Lib<@NullnessUnspecified Object[]> l)26   abstract void useArrayOfUnspec(Lib<@NullnessUnspecified Object[]> l);
27 
useArrayOfUnionNull(Lib<@Nullable Object[]> l)28   abstract void useArrayOfUnionNull(Lib<@Nullable Object[]> l);
29 
client(Lib<Object[]> l)30   void client(Lib<Object[]> l) {
31     useArray(l);
32     // jspecify_nullness_not_enough_information
33     useArrayOfUnspec(l);
34     // jspecify_nullness_mismatch
35     useArrayOfUnionNull(l);
36   }
37 
clientUnspec(Lib<@NullnessUnspecified Object[]> l)38   void clientUnspec(Lib<@NullnessUnspecified Object[]> l) {
39     // jspecify_nullness_not_enough_information
40     useArray(l);
41     // jspecify_nullness_not_enough_information
42     useArrayOfUnspec(l);
43     // jspecify_nullness_not_enough_information
44     useArrayOfUnionNull(l);
45   }
46 
clientUnionNull(Lib<@Nullable Object[]> l)47   void clientUnionNull(Lib<@Nullable Object[]> l) {
48     // jspecify_nullness_mismatch
49     useArray(l);
50     // jspecify_nullness_not_enough_information
51     useArrayOfUnspec(l);
52     useArrayOfUnionNull(l);
53   }
54 }
55