mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[java-highlighting] IDEA-353876 Support intersection type for switch selectors
GitOrigin-RevId: 075363ad27e93718b10b79234904eed7ac919436
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e198cda518
commit
7327bf910a
@@ -1036,6 +1036,11 @@ final class PatternHighlightingModel {
|
||||
.filter(t -> t != null)
|
||||
.forEach(t -> selectorTypes.add(t));
|
||||
}
|
||||
if (selectorType instanceof PsiIntersectionType psiIntersectionType) {
|
||||
for (PsiType conjunct : psiIntersectionType.getConjuncts()) {
|
||||
selectorTypes.addAll(getAllTypes(conjunct));
|
||||
}
|
||||
}
|
||||
if (selectorTypes.isEmpty()) {
|
||||
selectorTypes.add(selectorType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package dfa;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public final class ExhaustivenessWithIntersectionType {
|
||||
|
||||
public static void main(String[] ignoredArgs) {
|
||||
CompletableFuture
|
||||
.supplyAsync(() -> new Random().nextBoolean() ? new Result.Success() : new Result.Failure())
|
||||
.thenApply(res ->
|
||||
switch (res) {
|
||||
case Result.Success _ -> 1;
|
||||
case Result.Failure _ -> 2;
|
||||
})
|
||||
.thenAccept(System.out::println);
|
||||
}
|
||||
|
||||
sealed interface Result {
|
||||
record Success() implements Result { }
|
||||
|
||||
record Failure() implements Result { }
|
||||
}
|
||||
}
|
||||
@@ -214,6 +214,10 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
}
|
||||
|
||||
public void testExhaustivenessWithIntersectionType() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_22, this::doTest);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
|
||||
Reference in New Issue
Block a user