[java-highlighting] IDEA-324708 Coverage with 2 sealed hierarchies

GitOrigin-RevId: c38172bc2a5f16c29a7587f798d889da1c9d80eb
This commit is contained in:
Mikhail Pyltsin
2023-07-10 13:58:21 +02:00
committed by intellij-monorepo-bot
parent 20285c8d02
commit 9add8b349e
2 changed files with 16 additions and 1 deletions

View File

@@ -656,7 +656,7 @@ public class SwitchBlockHighlightingModel {
holder.add(info.create());
return;
}
if (!TypeConversionUtil.areTypesConvertible(mySelectorType, patternType) ||
if (!ContainerUtil.and(getAllTypes(mySelectorType), type -> TypeConversionUtil.areTypesConvertible(type, 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 checkcast convertible to U (JEP 440-441)
// There is no rule that says that a reference type applies to a primitive type

View File

@@ -93,4 +93,19 @@ class X {
}
native static boolean predicate();
sealed interface I1 {}
sealed interface I2 {}
record R1() implements I1 {}
record R2() implements I2 {}
record R3() implements I1, I2 {};
public class Test22{
public <T extends I1 & I2> void test(T c) {
switch (c) {
case <error descr="Incompatible types. Found: 'X.R2', required: 'T'">R2 r1</error> -> System.out.println(5);
case R3 r1 -> System.out.println(1);
}
}
}
}