| 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 typeparameterbounds; |
| 17 |
|
| 18 |
import org.jspecify.annotations.NullMarked; |
| 19 |
import org.jspecify.annotations.Nullable; |
| 20 |
import org.jspecify.annotations.NullnessUnspecified; |
| 21 |
|
| 22 |
@NullMarked |
| 23 |
class A<T> { |
| 24 |
public void foo(@NullnessUnspecified T t) {} |
| 25 |
|
| 26 |
public <E> void bar(E e) {} |
| 27 |
} |
| 28 |
|
| 29 |
@NullMarked |
| 30 |
class B<T> { |
| 31 |
public void foo(T t) {} |
| 32 |
|
| 33 |
public <E> void bar(E e) {} |
| 34 |
} |
| 35 |
|
| 36 |
class Test {} |
| 37 |
|
| 38 |
@NullMarked |
| 39 |
public class TypeParameterBounds { |
| 40 |
<T extends Test> void main( |
| 41 |
// jspecify_nullness_mismatch |
| 42 |
A<@Nullable Object> a1, A<Test> a2, B<@Nullable Object> b1, B<Test> b2, T x) { |
| 43 |
a1.foo(null); |
| 44 |
// jspecify_nullness_mismatch |
| 45 |
a1.<@Nullable T>bar(null); |
| 46 |
a1.<T>bar(x); |
| 47 |
|
| 48 |
// jspecify_nullness_not_enough_information |
| 49 |
a2.foo(null); |
| 50 |
// jspecify_nullness_mismatch |
| 51 |
a2.<@Nullable T>bar(null); |
| 52 |
a2.<T>bar(x); |
| 53 |
|
| 54 |
// jspecify_nullness_mismatch |
| 55 |
b1.foo(null); |
| 56 |
// jspecify_nullness_mismatch |
| 57 |
b1.<@Nullable T>bar(null); |
| 58 |
b1.<T>bar(x); |
| 59 |
|
| 60 |
// jspecify_nullness_mismatch |
| 61 |
b2.foo(null); |
| 62 |
// jspecify_nullness_mismatch |
| 63 |
b2.<@Nullable T>bar(null); |
| 64 |
b2.<T>bar(x); |
| 65 |
} |
| 66 |
} |