mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
[java-psi] IDEA-377693 Support unbounded wildcards
Better implementation through the PsiCapturedWildcardType GitOrigin-RevId: 35c30dcf936bd96e17c72795cc6fe09a370ccb9e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca97498b37
commit
960e3448ae
@@ -1,6 +1,9 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.codeInsight.Nullability;
|
||||
import com.intellij.codeInsight.NullabilityAnnotationInfo;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.TypeNullability;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.RecursionGuard;
|
||||
@@ -92,7 +95,19 @@ public final class PsiCapturedWildcardType extends PsiType.Stub {
|
||||
@Override
|
||||
public @NotNull TypeNullability getNullability() {
|
||||
if (myNullability == null) {
|
||||
myNullability = myExistential.getNullability();
|
||||
TypeNullability nullability = TypeNullability.UNKNOWN;
|
||||
if (myExistential.isBounded()) {
|
||||
nullability = myExistential.getNullability();
|
||||
} else {
|
||||
NullableNotNullManager manager = NullableNotNullManager.getInstance(myContext.getProject());
|
||||
if (manager != null) {
|
||||
NullabilityAnnotationInfo defaultNullability = manager.findDefaultTypeUseNullability(myContext);
|
||||
if (defaultNullability != null && defaultNullability.getNullability() == Nullability.NOT_NULL) {
|
||||
nullability = getUpperBound().getNullability();
|
||||
}
|
||||
}
|
||||
}
|
||||
myNullability = nullability;
|
||||
}
|
||||
return myNullability;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,6 @@ public class JSpecifyFilteredAnnotationTest extends JSpecifyAnnotationTest {
|
||||
new Pair<>("TypeVariableUnionNullToSelf.java", 118), // see: IDEA-377691
|
||||
new Pair<>("TypeVariableToParent.java", 94), // see: IDEA-377691
|
||||
|
||||
new Pair<>("NullUnmarkedUndoesNullMarkedForWildcards.java", 23), // see: IDEA-377693
|
||||
|
||||
new Pair<>("SuperObject.java", 31), // see: IDEA-377694
|
||||
new Pair<>("SuperTypeVariable.java", 28), // see: IDEA-377694
|
||||
new Pair<>("SuperTypeVariable.java", 57), // see: IDEA-377694
|
||||
|
||||
@@ -215,14 +215,13 @@ public final class PsiTypeNullabilityTest extends LightJavaCodeInsightFixtureTes
|
||||
|
||||
public void testWildcardAnnotated() {
|
||||
PsiType type = configureAndGetExpressionType("""
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class X<T> {
|
||||
class X<T extends @Nullable Object> {
|
||||
native X<@NotNull T> foo();
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
static void test(X<@Nullable ?> x) {
|
||||
@NotNullByDefault
|
||||
static void test(X<?> x) {
|
||||
<caret>x;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user