mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
EA-447738 [patterns for switch] - handle the case when permits list contains unresolved reference type
GitOrigin-RevId: 5a0adb3d51d548f40771a336d3fcbe76305be524
This commit is contained in:
committed by
intellij-monorepo-bot
parent
91ebcbfc9a
commit
f47870ae8a
@@ -28,6 +28,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel.PatternsInSwitchBlockHighlightingModel.CompletenessResult.*;
|
||||
import static com.intellij.psi.PsiModifier.ABSTRACT;
|
||||
@@ -863,7 +865,7 @@ public class SwitchBlockHighlightingModel {
|
||||
GlobalSearchScope fileScope = GlobalSearchScope.fileScope(psiClass.getContainingFile());
|
||||
return new ArrayList<>(DirectClassInheritorsSearch.search(psiClass, fileScope).findAll());
|
||||
}
|
||||
return ContainerUtil.map(permitsList.getReferencedTypes(), type -> type.resolve());
|
||||
return Stream.of(permitsList.getReferencedTypes()).map(type -> type.resolve()).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
class Test {
|
||||
void test(Sealed1 s1, Sealed2 s2) {
|
||||
switch (<error descr="'switch' statement does not cover all possible input values">s1</error>) {
|
||||
case A1 a -> System.out.println();
|
||||
}
|
||||
switch (s2) {
|
||||
case A2 a -> System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed abstract class Sealed1 permits A1, <error descr="Cannot resolve symbol 'B1'">B1</error>, C1 {
|
||||
}
|
||||
|
||||
final class A1 extends Sealed1 {
|
||||
}
|
||||
|
||||
final class C1 extends Sealed1 {
|
||||
}
|
||||
|
||||
sealed abstract class Sealed2 permits <error descr="Duplicate class: 'A2'">A2</error>, <error descr="Duplicate class: 'A2'">A2</error> {
|
||||
}
|
||||
|
||||
final class A2 extends Sealed2 {
|
||||
}
|
||||
@@ -117,6 +117,10 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBrokenSealedHierarchy() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
|
||||
Reference in New Issue
Block a user