1*2167191dSAndroid Build Coastguard Worker /* 2*2167191dSAndroid Build Coastguard Worker * Copyright 2020 The JSpecify Authors. 3*2167191dSAndroid Build Coastguard Worker * 4*2167191dSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*2167191dSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*2167191dSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*2167191dSAndroid Build Coastguard Worker * 8*2167191dSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*2167191dSAndroid Build Coastguard Worker * 10*2167191dSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*2167191dSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*2167191dSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*2167191dSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*2167191dSAndroid Build Coastguard Worker * limitations under the License. 15*2167191dSAndroid Build Coastguard Worker */ 16*2167191dSAndroid Build Coastguard Worker import org.jspecify.annotations.NullMarked; 17*2167191dSAndroid Build Coastguard Worker import org.jspecify.annotations.Nullable; 18*2167191dSAndroid Build Coastguard Worker import org.jspecify.annotations.NullnessUnspecified; 19*2167191dSAndroid Build Coastguard Worker 20*2167191dSAndroid Build Coastguard Worker /* 21*2167191dSAndroid Build Coastguard Worker * For the moment, we don't require support for parameter contravariance: 22*2167191dSAndroid Build Coastguard Worker * https://github.com/jspecify/jspecify/issues/49 23*2167191dSAndroid Build Coastguard Worker * 24*2167191dSAndroid Build Coastguard Worker * (If we change that, we should revise our samples README to explain that this is a case in which 25*2167191dSAndroid Build Coastguard Worker * we deviate from JLS rules: 26*2167191dSAndroid Build Coastguard Worker * https://github.com/jspecify/jspecify/blob/e55eb43f3bc1e7493b8b28a9dadd2b9b254e3335/samples/README.md#what-sample-inputs-demonstrate) 27*2167191dSAndroid Build Coastguard Worker */ 28*2167191dSAndroid Build Coastguard Worker @NullMarked 29*2167191dSAndroid Build Coastguard Worker class OverrideParameters { 30*2167191dSAndroid Build Coastguard Worker interface Super { useObject(Object o)31*2167191dSAndroid Build Coastguard Worker void useObject(Object o); 32*2167191dSAndroid Build Coastguard Worker useObjectUnspec(@ullnessUnspecified Object o)33*2167191dSAndroid Build Coastguard Worker void useObjectUnspec(@NullnessUnspecified Object o); 34*2167191dSAndroid Build Coastguard Worker useObjectUnionNull(@ullable Object o)35*2167191dSAndroid Build Coastguard Worker void useObjectUnionNull(@Nullable Object o); 36*2167191dSAndroid Build Coastguard Worker } 37*2167191dSAndroid Build Coastguard Worker 38*2167191dSAndroid Build Coastguard Worker interface SubObject extends Super { 39*2167191dSAndroid Build Coastguard Worker @Override useObject(Object o)40*2167191dSAndroid Build Coastguard Worker void useObject(Object o); 41*2167191dSAndroid Build Coastguard Worker 42*2167191dSAndroid Build Coastguard Worker @Override 43*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_not_enough_information useObjectUnspec(Object o)44*2167191dSAndroid Build Coastguard Worker void useObjectUnspec(Object o); 45*2167191dSAndroid Build Coastguard Worker 46*2167191dSAndroid Build Coastguard Worker @Override 47*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_mismatch useObjectUnionNull(Object o)48*2167191dSAndroid Build Coastguard Worker void useObjectUnionNull(Object o); 49*2167191dSAndroid Build Coastguard Worker } 50*2167191dSAndroid Build Coastguard Worker 51*2167191dSAndroid Build Coastguard Worker interface SubObjectUnspec extends Super { 52*2167191dSAndroid Build Coastguard Worker @Override 53*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_not_enough_information useObject(@ullnessUnspecified Object o)54*2167191dSAndroid Build Coastguard Worker void useObject(@NullnessUnspecified Object o); 55*2167191dSAndroid Build Coastguard Worker 56*2167191dSAndroid Build Coastguard Worker @Override 57*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_not_enough_information useObjectUnspec(@ullnessUnspecified Object o)58*2167191dSAndroid Build Coastguard Worker void useObjectUnspec(@NullnessUnspecified Object o); 59*2167191dSAndroid Build Coastguard Worker 60*2167191dSAndroid Build Coastguard Worker @Override 61*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_not_enough_information useObjectUnionNull(@ullnessUnspecified Object o)62*2167191dSAndroid Build Coastguard Worker void useObjectUnionNull(@NullnessUnspecified Object o); 63*2167191dSAndroid Build Coastguard Worker } 64*2167191dSAndroid Build Coastguard Worker 65*2167191dSAndroid Build Coastguard Worker interface SubObjectUnionNull extends Super { 66*2167191dSAndroid Build Coastguard Worker @Override 67*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_mismatch useObject(@ullable Object o)68*2167191dSAndroid Build Coastguard Worker void useObject(@Nullable Object o); 69*2167191dSAndroid Build Coastguard Worker 70*2167191dSAndroid Build Coastguard Worker @Override 71*2167191dSAndroid Build Coastguard Worker // jspecify_nullness_not_enough_information useObjectUnspec(@ullable Object o)72*2167191dSAndroid Build Coastguard Worker void useObjectUnspec(@Nullable Object o); 73*2167191dSAndroid Build Coastguard Worker 74*2167191dSAndroid Build Coastguard Worker @Override useObjectUnionNull(@ullable Object o)75*2167191dSAndroid Build Coastguard Worker void useObjectUnionNull(@Nullable Object o); 76*2167191dSAndroid Build Coastguard Worker } 77*2167191dSAndroid Build Coastguard Worker } 78