Change parser error for when (KT-6420)
#KT-6420 Fixed
This commit is contained in:
@@ -847,7 +847,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
advance(); // COMMA
|
advance(); // COMMA
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(ARROW, "Expecting '->' or 'when'", WHEN_CONDITION_RECOVERY_SET);
|
expect(ARROW, "Expecting '->'", WHEN_CONDITION_RECOVERY_SET);
|
||||||
if (atSet(WHEN_CONDITION_RECOVERY_SET)) {
|
if (atSet(WHEN_CONDITION_RECOVERY_SET)) {
|
||||||
error("Expecting an element");
|
error("Expecting an element");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun test() {
|
||||||
|
when(element) {
|
||||||
|
is JetProperty when { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
JetFile: NoArrowInWhen.kt
|
||||||
|
PACKAGE_DIRECTIVE
|
||||||
|
<empty list>
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('test')
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
WHEN
|
||||||
|
PsiElement(when)('when')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('element')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
WHEN_ENTRY
|
||||||
|
WHEN_CONDITION_IS_PATTERN
|
||||||
|
PsiElement(is)('is')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('JetProperty')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiErrorElement:Expecting '->'
|
||||||
|
PsiElement(when)('when')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -1395,6 +1395,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
|||||||
doParsingTest(fileName);
|
doParsingTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NoArrowInWhen.kt")
|
||||||
|
public void testNoArrowInWhen() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/NoArrowInWhen.kt");
|
||||||
|
doParsingTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("PackageNewLineRecovery.kt")
|
@TestMetadata("PackageNewLineRecovery.kt")
|
||||||
public void testPackageNewLineRecovery() throws Exception {
|
public void testPackageNewLineRecovery() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/PackageNewLineRecovery.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/recovery/PackageNewLineRecovery.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user