mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Switch label: do not resolve unqualified enum constants referenced on the right side of arrow
Fixes IDEA-210771 Error message should be exposed for the new 'case' label in Java 12 in case of wrong constant usage
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ public abstract class PsiSwitchLabelStatementBaseImpl extends CompositePsiElemen
|
||||
@NotNull ResolveState state,
|
||||
PsiElement lastParent,
|
||||
@NotNull PsiElement place) {
|
||||
if (lastParent != null) {
|
||||
if (lastParent instanceof PsiExpressionList) {
|
||||
PsiSwitchBlock switchStatement = getEnclosingSwitchBlock();
|
||||
if (switchStatement != null) {
|
||||
PsiExpression expression = switchStatement.getExpression();
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.Random;
|
||||
|
||||
class SwitchExpressionsEnumResolve {
|
||||
enum E { E1, E2 }
|
||||
|
||||
E test(E e) {
|
||||
return switch (e) {
|
||||
case E1 -> <error descr="Cannot resolve symbol 'E2'">E2</error>;
|
||||
case E2 -> <error descr="Cannot resolve symbol 'E1'">E1</error>;
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
@@ -10,6 +10,7 @@ class LightJava12HighlightingTest : LightCodeInsightFixtureTestCase() {
|
||||
|
||||
fun testEnhancedSwitchStatements() = doTest()
|
||||
fun testSwitchExpressions() = doTest()
|
||||
fun testSwitchExpressionsEnumResolve() = doTest()
|
||||
fun testValueBreaks() = doTest()
|
||||
fun testSwitchNumericPromotion() = doTest()
|
||||
fun testSimpleInferenceCases() = doTest()
|
||||
|
||||
Reference in New Issue
Block a user