[java-analysis] IDEA-375470 Type parameter with nullable bound within NullMarked scope should be nullable

GitOrigin-RevId: c8c264ab40180c7982ac8d5d886841323578348b
This commit is contained in:
Tagir Valeev
2025-07-04 15:05:13 +00:00
committed by intellij-monorepo-bot
parent 6c7bdfdace
commit 0cb6e48c04
3 changed files with 22 additions and 1 deletions
@@ -115,6 +115,10 @@ public final class TypeNullability {
}
public static @NotNull TypeNullability ofTypeParameter(@NotNull PsiTypeParameter parameter) {
TypeNullability nullability = intersect(ContainerUtil.map(parameter.getSuperTypes(), PsiType::getNullability)).inherited();
if (!nullability.equals(UNKNOWN)) {
return nullability;
}
NullableNotNullManager manager = NullableNotNullManager.getInstance(parameter.getProject());
if (manager != null) {
NullabilityAnnotationInfo typeUseNullability = manager.findDefaultTypeUseNullability(parameter);
@@ -122,7 +126,7 @@ public final class TypeNullability {
return typeUseNullability.toTypeNullability();
}
}
return intersect(ContainerUtil.map(parameter.getSuperTypes(), PsiType::getNullability)).inherited();
return UNKNOWN;
}
/**
@@ -0,0 +1,11 @@
import org.jspecify.annotations.*;
@NullMarked
class Test2 {
void call(Test<? extends Base, ? extends @Nullable Base> a) {}
}
class Base {}
@NullMarked
class Test<T, E extends @Nullable Object> {}
@@ -483,4 +483,10 @@ public class NullableStuffInspectionTest extends LightJavaCodeInsightFixtureTest
setupTypeUseAnnotations("org.jspecify.annotations", myFixture);
doTest();
}
public void testNullableExtendsNullable() {
addJSpecifyNullMarked(myFixture);
setupTypeUseAnnotations("org.jspecify.annotations", myFixture);
doTest();
}
}