Mute syntax error when function name was omitted
This commit is contained in:
@@ -1038,7 +1038,7 @@ public class JetParsing extends AbstractJetParsing {
|
||||
errorIf(multiDecl, !local, "Multi-declarations are only allowed for local variables/values");
|
||||
}
|
||||
else {
|
||||
parseFunctionOrPropertyName(receiverTypeDeclared, "property", propertyNameFollow);
|
||||
parseFunctionOrPropertyName(receiverTypeDeclared, "property", propertyNameFollow, /*nameRequired = */ false);
|
||||
}
|
||||
|
||||
myBuilder.restoreJoiningComplexTokensState();
|
||||
@@ -1238,7 +1238,8 @@ public class JetParsing extends AbstractJetParsing {
|
||||
TokenSet functionNameFollow = TokenSet.create(LT, LPAR, COLON, EQ);
|
||||
boolean receiverFound = parseReceiverType("function", functionNameFollow);
|
||||
|
||||
parseFunctionOrPropertyName(receiverFound, "function", functionNameFollow);
|
||||
// function as expression has no name
|
||||
parseFunctionOrPropertyName(receiverFound, "function", functionNameFollow, /*nameRequired = */ true);
|
||||
|
||||
myBuilder.restoreJoiningComplexTokensState();
|
||||
|
||||
@@ -1350,7 +1351,9 @@ public class JetParsing extends AbstractJetParsing {
|
||||
/*
|
||||
* IDENTIFIER
|
||||
*/
|
||||
private void parseFunctionOrPropertyName(boolean receiverFound, String title, TokenSet nameFollow) {
|
||||
private void parseFunctionOrPropertyName(boolean receiverFound, String title, TokenSet nameFollow, boolean nameRequired) {
|
||||
if (nameRequired && atSet(nameFollow)) return; // no name
|
||||
|
||||
if (!receiverFound) {
|
||||
expect(IDENTIFIER, "Expecting " + title + " name or receiver type", nameFollow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user