mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
[java-psi] IDEA-377644 PsiImmediateClassType, PsiArrayType: reset nullability when annotations changed
Also: do not merge annotations during the substitution (unnecessary anymore after nullability is implemented and causes problems) Some tests that rely on annotation merging during the substitution are removed/updated. The behavior was inconsistent anyway. GitOrigin-RevId: c13e68616507bbb10cbe0384d122334879e166df
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4f1f7eaf8a
commit
fbd13ff64c
@@ -7,6 +7,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.JavaTypeNullabilityUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an array type.
|
||||
@@ -15,7 +16,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class PsiArrayType extends PsiType.Stub implements JvmArrayType {
|
||||
private final PsiType myComponentType;
|
||||
private final TypeNullability myNullability;
|
||||
private TypeNullability myNullability;
|
||||
|
||||
public PsiArrayType(@NotNull PsiType componentType) {
|
||||
this(componentType, TypeAnnotationProvider.EMPTY);
|
||||
@@ -24,14 +25,14 @@ public class PsiArrayType extends PsiType.Stub implements JvmArrayType {
|
||||
public PsiArrayType(@NotNull PsiType componentType, PsiAnnotation @NotNull [] annotations) {
|
||||
super(annotations);
|
||||
myComponentType = componentType;
|
||||
myNullability = JavaTypeNullabilityUtil.getNullabilityFromAnnotations(annotations);
|
||||
myNullability = null;
|
||||
}
|
||||
|
||||
public PsiArrayType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider) {
|
||||
this(componentType, provider, JavaTypeNullabilityUtil.getNullabilityFromAnnotations(provider.getAnnotations()));
|
||||
this(componentType, provider, null);
|
||||
}
|
||||
|
||||
PsiArrayType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider, @NotNull TypeNullability nullability) {
|
||||
PsiArrayType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider, @Nullable TypeNullability nullability) {
|
||||
super(provider);
|
||||
myComponentType = componentType;
|
||||
myNullability = nullability;
|
||||
@@ -121,6 +122,9 @@ public class PsiArrayType extends PsiType.Stub implements JvmArrayType {
|
||||
|
||||
@Override
|
||||
public @NotNull TypeNullability getNullability() {
|
||||
if (myNullability == null) {
|
||||
myNullability = JavaTypeNullabilityUtil.getNullabilityFromAnnotations(getAnnotations());
|
||||
}
|
||||
return myNullability;
|
||||
}
|
||||
|
||||
@@ -134,6 +138,15 @@ public class PsiArrayType extends PsiType.Stub implements JvmArrayType {
|
||||
return new PsiArrayType(getComponentType(), getAnnotationProvider(), nullability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PsiArrayType annotate(@NotNull TypeAnnotationProvider provider) {
|
||||
PsiArrayType annotated = (PsiArrayType)super.annotate(provider);
|
||||
if (annotated != this) {
|
||||
annotated.myNullability = null;
|
||||
}
|
||||
return annotated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PsiArrayType &&
|
||||
|
||||
Reference in New Issue
Block a user