Revert "[java-psi] IDEA-377693 Support unbounded wildcards"

This reverts commit 5283895c887c59b3b4386c51ce2a06c67688e170.

GitOrigin-RevId: b56c4733616caed180dc170d6b73a30d0eb31321
This commit is contained in:
Tagir Valeev
2025-10-01 15:50:23 +00:00
committed by intellij-monorepo-bot
parent 246ef04856
commit ca97498b37
9 changed files with 18 additions and 74 deletions
@@ -34,12 +34,6 @@ interface ContextNullabilityInfo {
public @NotNull ContextNullabilityInfo filtering(@NotNull Predicate<@NotNull PsiElement> contextFilter) {
return this;
}
@Override
public @NotNull ContextNullabilityInfo withNullabilityInContext(@NotNull Predicate<@NotNull PsiElement> contextFilter,
@NotNull Nullability nullability) {
return this;
}
};
/**
@@ -74,15 +68,6 @@ interface ContextNullabilityInfo {
default @NotNull ContextNullabilityInfo filtering(@NotNull Predicate<@NotNull PsiElement> contextFilter) {
return context -> contextFilter.test(context) ? forContext(context) : null;
}
default @NotNull ContextNullabilityInfo withNullabilityInContext(@NotNull Predicate<@NotNull PsiElement> contextFilter,
@NotNull Nullability nullability) {
return context -> {
NullabilityAnnotationInfo info = forContext(context);
if (info == null) return null;
return contextFilter.test(context) ? new NullabilityAnnotationInfo(info.getAnnotation(), nullability, info.isContainer()) : info;
};
}
/**
* @return a new {@code ContextNullabilityInfo} that filters out the cast contexts.
@@ -81,9 +81,7 @@ public final class TypeNullability {
if (this.nullability() == Nullability.NULLABLE && this.source() instanceof NullabilitySource.ExtendsBound) {
return nullability;
}
if ((nullability.nullability() == Nullability.NOT_NULL ||
nullability.nullability() == Nullability.UNKNOWN && !nullability.source().equals(NullabilitySource.Standard.NONE))
&& this.source() instanceof NullabilitySource.ExtendsBound) {
if (nullability.nullability() == Nullability.NOT_NULL && this.source() instanceof NullabilitySource.ExtendsBound) {
return nullability;
}
if (this.source() == NullabilitySource.Standard.NONE) {
@@ -58,18 +58,6 @@ public interface PsiTypeElement extends PsiElement, PsiAnnotationOwner {
return false;
}
/**
* Returns true if the type element represents an unbounded wildcard type like {@code ?} (possibly annotated).
* Strictly speaking, {@code isUnboundedWildcard() == getType() instanceof PsiWildcardType wt && !wt.isBounded()}.
* This method can be helpful for nullability annotation processing to avoid computing the type,
* as the type may in turn depend on the nullability.
*
* @return true if the type element represents an unbounded wildcard.
*/
default boolean isUnboundedWildcard() {
return getText().endsWith("?");
}
/**
* @return false if annotations cannot be added to this type element
* For example, the JVM language that doesn't support type-use annotations;
@@ -74,13 +74,11 @@ public final class PsiWildcardType extends PsiType.Stub implements JvmWildcardTy
@Override
public @NotNull PsiWildcardType withNullability(@NotNull TypeNullability nullability) {
if (nullability == getNullability()) return this;
return new PsiWildcardType(myManager, myIsExtending, myBound, getAnnotationProvider(), nullability);
}
@Override
public @NotNull PsiType annotate(@NotNull TypeAnnotationProvider provider) {
if (getAnnotationProvider() == provider) return this;
return new PsiWildcardType(myManager, myIsExtending, myBound, provider);
}