Debian Codegraph @

samples/wildcardsWithDefault/wildcardswithdefault/WildcardsWithDefault.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 package wildcardswithdefault;
17
18 import org.jspecify.annotations.NullMarked;
19 import org.jspecify.annotations.Nullable;
20 import org.jspecify.annotations.NullnessUnspecified;
21
22 @NullMarked
23 public class WildcardsWithDefault {
24 public void noBoundsNotNull(A<?, ?, ?> a) {}
25
26 public void noBoundsNullable(
27 A<? extends @Nullable Object, ? extends @Nullable Object, ? extends @Nullable Object> a) {}
28 }
29
30 @NullMarked
31 class A<T extends Object, E extends @Nullable Object, F extends @NullnessUnspecified Object> {}
32
33 @NullMarked
34 class Use {
35 public static void main(
36 A<Object, Object, Object> aNotNullNotNullNotNull,
37 // jspecify_nullness_not_enough_information
38 A<Object, Object, @Nullable Object> aNotNullNotNullNull,
39 A<Object, @Nullable Object, Object> aNotNullNullNotNull,
40 // jspecify_nullness_not_enough_information
41 A<Object, @Nullable Object, @Nullable Object> aNotNullNullNull,
42 WildcardsWithDefault b) {
43 b.noBoundsNotNull(aNotNullNotNullNotNull);
44 b.noBoundsNotNull(aNotNullNotNullNull);
45 b.noBoundsNotNull(aNotNullNullNotNull);
46 b.noBoundsNotNull(aNotNullNullNull);
47
48 b.noBoundsNullable(aNotNullNotNullNotNull);
49 b.noBoundsNullable(aNotNullNotNullNull);
50 b.noBoundsNullable(aNotNullNullNotNull);
51 b.noBoundsNullable(aNotNullNullNull);
52 }
53 }