[java-psi] PsiEllipsisType#withNullability

Part of IDEA-372347 Java type inference should respect nullability

GitOrigin-RevId: b612892b0c932d06118615231fd1980ebc386717
This commit is contained in:
Tagir Valeev
2025-05-30 17:35:52 +02:00
committed by intellij-monorepo-bot
parent 28463a9345
commit 33488fe4c6
2 changed files with 11 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ public class PsiArrayType extends PsiType.Stub implements JvmArrayType {
this(componentType, provider, JavaTypeNullabilityUtil.getNullabilityFromAnnotations(provider.getAnnotations()));
}
private PsiArrayType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider, @NotNull TypeNullability nullability) {
PsiArrayType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider, @NotNull TypeNullability nullability) {
super(provider);
myComponentType = componentType;
myNullability = nullability;

View File

@@ -1,6 +1,7 @@
// 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.TypeNullability;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@@ -19,6 +20,10 @@ public class PsiEllipsisType extends PsiArrayType {
public PsiEllipsisType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider) {
super(componentType, provider);
}
private PsiEllipsisType(@NotNull PsiType componentType, @NotNull TypeAnnotationProvider provider, @NotNull TypeNullability nullability) {
super(componentType, provider, nullability);
}
@Override
public @NotNull String getPresentableText(boolean annotated) {
@@ -41,6 +46,11 @@ public class PsiEllipsisType extends PsiArrayType {
super.equalsToText(text);
}
@Override
public @NotNull PsiEllipsisType withNullability(@NotNull TypeNullability nullability) {
return new PsiEllipsisType(getComponentType(), getAnnotationProvider(), nullability);
}
/**
* Converts the ellipsis type to an array type with the same component type.
*