Don't parse entries if left brace absent in 'when'
This commit is contained in:
@@ -780,13 +780,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
// Parse when block
|
||||
myBuilder.enableNewlines();
|
||||
expect(LBRACE, "Expecting '{'");
|
||||
if (expect(LBRACE, "Expecting '{'")) {
|
||||
while (!eof() && !at(RBRACE)) {
|
||||
parseWhenEntry();
|
||||
}
|
||||
|
||||
while (!eof() && !at(RBRACE)) {
|
||||
parseWhenEntry();
|
||||
expect(RBRACE, "Expecting '}'");
|
||||
}
|
||||
|
||||
expect(RBRACE, "Expecting '}'");
|
||||
myBuilder.restoreNewlinesState();
|
||||
|
||||
when.done(WHEN);
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
fun test(a: Any) {
|
||||
when (a)<!SYNTAX!><!>
|
||||
}<!SYNTAX!><!>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun test() {
|
||||
when
|
||||
|
||||
bar()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
JetFile: WhenWithoutBraces.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')
|
||||
PsiErrorElement:Expecting '{'
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n\n ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
VALUE_ARGUMENT_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -1015,6 +1015,11 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
||||
doParsingTest("compiler/testData/psi/recovery/ValueParameterNoTypeRecovery.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WhenWithoutBraces.kt")
|
||||
public void testWhenWithoutBraces() throws Exception {
|
||||
doParsingTest("compiler/testData/psi/recovery/WhenWithoutBraces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WhileWithEmptyCondition.kt")
|
||||
public void testWhileWithEmptyCondition() throws Exception {
|
||||
doParsingTest("compiler/testData/psi/recovery/WhileWithEmptyCondition.kt");
|
||||
|
||||
Reference in New Issue
Block a user