diff --git a/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java b/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java index 6b15f91..c13bab0 100644 --- a/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java +++ b/src/main/java/com/google/jspecify/nullness/NullSpecAnnotatedTypeFactory.java @@ -531,6 +531,14 @@ public boolean isParametricQualifier(AnnotationMirror qualifier) { } } + @Override + public AnnotatedTypeMirror applyCaptureConversion( + AnnotatedTypeMirror type, TypeMirror typeMirror) { + return this == withLeastConvenientWorld + ? super.applyCaptureConversion(type, typeMirror) + : withLeastConvenientWorld.applyCaptureConversion(type, typeMirror); + } + @Override protected TypeHierarchy createTypeHierarchy() { return new NullSpecTypeHierarchy( diff --git a/tests/regression/Issue197.java b/tests/regression/Issue197.java new file mode 100644 index 0000000..eac3ca6 --- /dev/null +++ b/tests/regression/Issue197.java @@ -0,0 +1,33 @@ +// Copyright 2024 The JSpecify Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Test case for Issue 197: +// https://github.com/jspecify/jspecify-reference-checker/issues/197 + +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +class Issue197 { + interface Function {} + + interface Super { + void i(Function p); + } + + @NullMarked + interface Sub extends Super { + @Override + void i(Function p); + } +}