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 @NullMarked 21 class UseOfTypeVariableUnionNullAsTypeArgument { 22 interface Lib<T extends @Nullable Object> {} 23 24 interface Super<T extends @Nullable Object> { get()25 Lib<@Nullable T> get(); 26 } 27 28 interface SubObject extends Super<Object> {} 29 30 interface SubObjectUnspec extends Super<@NullnessUnspecified Object> {} 31 32 interface SubObjectUnionNull extends Super<@Nullable Object> {} 33 34 class Caller { x0(SubObject s)35 Lib<? extends Object> x0(SubObject s) { 36 // jspecify_nullness_mismatch 37 return s.get(); 38 } 39 x1(SubObjectUnspec s)40 Lib<? extends Object> x1(SubObjectUnspec s) { 41 // jspecify_nullness_mismatch 42 return s.get(); 43 } 44 x2(SubObjectUnionNull s)45 Lib<? extends Object> x2(SubObjectUnionNull s) { 46 // jspecify_nullness_mismatch 47 return s.get(); 48 } 49 x3(Super<Object> s)50 Lib<? extends Object> x3(Super<Object> s) { 51 // jspecify_nullness_mismatch 52 return s.get(); 53 } 54 x4(Super<@NullnessUnspecified Object> s)55 Lib<? extends Object> x4(Super<@NullnessUnspecified Object> s) { 56 // jspecify_nullness_mismatch 57 return s.get(); 58 } 59 x5(Super<@Nullable Object> s)60 Lib<? extends Object> x5(Super<@Nullable Object> s) { 61 // jspecify_nullness_mismatch 62 return s.get(); 63 } 64 x6(Super<? extends Object> s)65 Lib<? extends Object> x6(Super<? extends Object> s) { 66 // jspecify_nullness_mismatch 67 return s.get(); 68 } 69 x7(Super<? extends @NullnessUnspecified Object> s)70 Lib<? extends Object> x7(Super<? extends @NullnessUnspecified Object> s) { 71 // jspecify_nullness_mismatch 72 return s.get(); 73 } 74 x8(Super<? extends @Nullable Object> s)75 Lib<? extends Object> x8(Super<? extends @Nullable Object> s) { 76 // jspecify_nullness_mismatch 77 return s.get(); 78 } 79 x9(Super<?> s)80 Lib<? extends Object> x9(Super<?> s) { 81 // jspecify_nullness_mismatch 82 return s.get(); 83 } 84 } 85 } 86