Mute syntax error when function name was omitted

This commit is contained in:
Stanislav Erokhin
2015-02-05 19:24:16 +03:00
parent a33450395c
commit a8536fef9b
8 changed files with 848 additions and 3 deletions
@@ -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);
}