Debian Codegraph @

samples/OverrideParameters.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 /*
21 * For the moment, we don't require support for parameter contravariance:
22 * https://github.com/jspecify/jspecify/issues/49
23 *
24 * (If we change that, we should revise our samples README to explain that this is a case in which
25 * we deviate from JLS rules:
26 * https://github.com/jspecify/jspecify/blob/e55eb43f3bc1e7493b8b28a9dadd2b9b254e3335/samples/README.md#what-sample-inputs-demonstrate)
27 */
28 @NullMarked
29 class OverrideParameters {
30 interface Super {
31 void useObject(Object o);
32
33 void useObjectUnspec(@NullnessUnspecified Object o);
34
35 void useObjectUnionNull(@Nullable Object o);
36 }
37
38 interface SubObject extends Super {
39 @Override
40 void useObject(Object o);
41
42 @Override
43 // jspecify_nullness_not_enough_information
44 void useObjectUnspec(Object o);
45
46 @Override
47 // jspecify_nullness_mismatch
48 void useObjectUnionNull(Object o);
49 }
50
51 interface SubObjectUnspec extends Super {
52 @Override
53 // jspecify_nullness_not_enough_information
54 void useObject(@NullnessUnspecified Object o);
55
56 @Override
57 // jspecify_nullness_not_enough_information
58 void useObjectUnspec(@NullnessUnspecified Object o);
59
60 @Override
61 // jspecify_nullness_not_enough_information
62 void useObjectUnionNull(@NullnessUnspecified Object o);
63 }
64
65 interface SubObjectUnionNull extends Super {
66 @Override
67 // jspecify_nullness_mismatch
68 void useObject(@Nullable Object o);
69
70 @Override
71 // jspecify_nullness_not_enough_information
72 void useObjectUnspec(@Nullable Object o);
73
74 @Override
75 void useObjectUnionNull(@Nullable Object o);
76 }
77 }