[java-highlighting] IDEA-323767 Rename "Downcast compatible" -> "checked cast compatible"

GitOrigin-RevId: 6ac91a8fde1cae06a0892847b3ae24db1fdd9d0f
This commit is contained in:
Mikhail Pyltsin
2023-07-03 13:45:16 +02:00
committed by intellij-monorepo-bot
parent ac1a73d5ee
commit 2be6bd8458
3 changed files with 6 additions and 12 deletions

View File

@@ -599,11 +599,8 @@ public class SwitchBlockHighlightingModel {
}
if (!TypeConversionUtil.areTypesConvertible(mySelectorType, patternType) ||
// 14.30.3 A type pattern that declares a pattern variable of a reference type U is
// applicable at another reference type T if T is downcast convertible to U (JEP 427)
// applicable at another reference type T if T is checkcast convertible to U (JEP 427)
// There is no rule that says that a reference type applies to a primitive type
// There is no restriction on primitive types in JEP 406 and JEP 420:
// 14.30.1 An expression e is compatible with a pattern if the pattern is of type T
// and e is downcast compatible with T
(mySelectorType instanceof PsiPrimitiveType && HighlightingFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(label))) {
HighlightInfo error =
HighlightUtil.createIncompatibleTypeHighlightInfo(mySelectorType, patternType, elementToReport.getTextRange(), 0).create();

View File

@@ -818,11 +818,8 @@ public final class RedundantCastUtil {
// 14.11.1 A null case element is switch compatible with T if T is a reference type (JEP 427)
if (branch instanceof PsiExpression expression && TypeConversionUtil.isNullType(expression.getType())) return;
// 14.30.3 A type pattern that declares a pattern variable of a reference type U is
// applicable at another reference type T if T is downcast convertible to U (JEP 427)
// applicable at another reference type T if T is checkcast convertible to U (JEP 427)
// There is no rule that says that a reference type applies to a primitive type
// There is no restriction on primitive types in JEP 406 and JEP 420:
// 14.30.1 An expression e is compatible with a pattern if the pattern is of type T
// and e is downcast compatible with T
if (branch instanceof PsiPattern || branch instanceof PsiPatternGuard) return;
}
}

View File

@@ -75,23 +75,23 @@ public class DeconstructionInstanceOf20 {
record Pair<T,T1>(T first, T1 second) {};
public static void notDowncastConvertible(){
public static void notCheckcastConvertible(){
Object o = "Some string";
if (o instanceof Pair(Integer x, String y)) {
System.out.println(x + " " + y);
} else {
System.out.println("notDowncastConvertible default branch");
System.out.println("notCheckcastConvertible default branch");
}
};
public static void downcastConvertible(){
public static void checkcastConvertible(){
Pair<Integer, String> pair = new Pair<>(42, "hello");
Object o = pair;
if (o instanceof Pair(Integer x, String y)) {
System.out.println(x + " " + y);
} else {
System.out.println("notDowncastConvertible default branch");
System.out.println("notCheckcastConvertible default branch");
}
};
}