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 UnionTypeArgumentWithUseSite { 22 interface Super<T extends @Nullable Object> { t(T t)23 void t(T t); 24 tUnspec(@ullnessUnspecified T t)25 void tUnspec(@NullnessUnspecified T t); 26 tUnionNull(@ullable T t)27 void tUnionNull(@Nullable T t); 28 } 29 30 interface Sub extends Super<Object> { 31 @Override t(Object t)32 void t(Object t); 33 34 @Override 35 // jspecify_nullness_not_enough_information tUnspec(@ullnessUnspecified Object t)36 void tUnspec(@NullnessUnspecified Object t); 37 38 @Override tUnionNull(@ullable Object t)39 void tUnionNull(@Nullable Object t); 40 } 41 42 interface SubUnspec extends Super<@NullnessUnspecified Object> { 43 @Override 44 // jspecify_nullness_not_enough_information t(@ullnessUnspecified Object t)45 void t(@NullnessUnspecified Object t); 46 47 @Override 48 // jspecify_nullness_not_enough_information tUnspec(@ullnessUnspecified Object t)49 void tUnspec(@NullnessUnspecified Object t); 50 51 @Override tUnionNull(@ullable Object t)52 void tUnionNull(@Nullable Object t); 53 } 54 55 interface SubUnionNull extends Super<@Nullable Object> { 56 @Override t(@ullable Object t)57 void t(@Nullable Object t); 58 59 @Override tUnspec(@ullable Object t)60 void tUnspec(@Nullable Object t); 61 62 @Override tUnionNull(@ullable Object t)63 void tUnionNull(@Nullable Object t); 64 } 65 66 interface SubWeaker extends Super<Object> { 67 @Override 68 // jspecify_nullness_not_enough_information tUnspec(Object t)69 void tUnspec(Object t); 70 71 @Override 72 // jspecify_nullness_mismatch tUnionNull(Object t)73 void tUnionNull(Object t); 74 } 75 76 interface SubWeakerUnspec extends Super<@NullnessUnspecified Object> { 77 @Override 78 // jspecify_nullness_not_enough_information t(Object t)79 void t(Object t); 80 81 @Override 82 // jspecify_nullness_not_enough_information tUnspec(Object t)83 void tUnspec(Object t); 84 85 @Override 86 // jspecify_nullness_mismatch tUnionNull(Object t)87 void tUnionNull(Object t); 88 } 89 90 interface SubWeakerUnionNull extends Super<@Nullable Object> { 91 @Override 92 // jspecify_nullness_mismatch t(Object t)93 void t(Object t); 94 95 @Override 96 // jspecify_nullness_mismatch tUnspec(Object t)97 void tUnspec(Object t); 98 99 @Override 100 // jspecify_nullness_mismatch tUnionNull(Object t)101 void tUnionNull(Object t); 102 } 103 } 104