diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index cf9afd78d2d..b39c57c3388 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -1074,7 +1074,8 @@ public class JetExpressionParsing extends AbstractJetParsing { // {a -> ...} // {a, b -> ...} PsiBuilder.Marker rollbackMarker = mark(); - boolean preferParamsToExpressions = (lookahead(1) == COMMA); + IElementType nextToken = lookahead(1); + boolean preferParamsToExpressions = (nextToken == COMMA || nextToken == COLON); parseFunctionLiteralShorthandParameterList(); paramsFound = preferParamsToExpressions ? @@ -1710,6 +1711,9 @@ public class JetExpressionParsing extends AbstractJetParsing { while (true) { while (at(COMMA)) errorAndAdvance("Expecting an argument"); parseValueArgument(); + if (at(COLON) && lookahead(1) == IDENTIFIER) { + errorAndAdvance("Unexpected type specification", 2); + } if (!at(COMMA)) break; advance(); // COMMA if (at(RPAR)) { diff --git a/compiler/testData/psi/FunctionLiterals.kt b/compiler/testData/psi/FunctionLiterals.kt index 846dfa4d972..ba766a3bc0e 100644 --- a/compiler/testData/psi/FunctionLiterals.kt +++ b/compiler/testData/psi/FunctionLiterals.kt @@ -5,32 +5,7 @@ fun foo() { {a -> a} - {(a) -> a} - {(a : A) -> a} - {(a : A) : T -> a} - {(a) : T -> a} - - {(a, a) -> a} - {(a : A, a : B) -> a} - {(a : A, a) : T -> a} - {(a, a : B) : T -> a} - - {() -> a} - {() -> a} - {() : T -> a} - {() : T -> a} - - {T.(a) -> a} - {T.(a : A) -> a} - {T.(a : A) : T -> a} - {T.(a) : T -> a} - {x, y -> 1} - {@[a] x, @[b] y, @[c] z -> 1} - - {((a: Int = object { fun t() {} }) -> Int).(x: Int) : String -> "" } - { A.B.(x: Int) -> } - {((a: Boolean = true) -> Int).(x: Any) : Unit -> } {a: b -> f} {a: b, c -> f} diff --git a/compiler/testData/psi/FunctionLiterals.txt b/compiler/testData/psi/FunctionLiterals.txt index ef1e3f28a75..aa4dc70a2d8 100644 --- a/compiler/testData/psi/FunctionLiterals.txt +++ b/compiler/testData/psi/FunctionLiterals.txt @@ -43,422 +43,6 @@ JetFile: FunctionLiterals.kt PsiElement(IDENTIFIER)('a') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiErrorElement:Expecting ')' - - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiErrorElement:Expecting ')' - - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('B') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiErrorElement:Expecting ')' - - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiErrorElement:Expecting ')' - - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('B') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - PsiErrorElement:Expecting an expression - - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - PsiErrorElement:Expecting an expression - - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - PsiErrorElement:Expecting an expression - - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - PsiErrorElement:Expecting an expression - - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') @@ -476,209 +60,6 @@ JetFile: FunctionLiterals.kt INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - ANNOTATED_EXPRESSION - ANNOTATION - PsiElement(AT)('@') - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiElement(LBRACKET)('[') - PsiElement(IDENTIFIER)('b') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('y') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiElement(LBRACKET)('[') - PsiElement(IDENTIFIER)('c') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('z') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_EXPRESSION - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace(' ') - FUN - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('t') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace(' ') - PsiElement(RBRACE)('}') - PsiElement(RPAR)(')') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiElement(DOT)('.') - PsiElement(LPAR)('(') - PsiElement(IDENTIFIER)('x') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('String') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(OPEN_QUOTE)('"') - PsiElement(CLOSING_QUOTE)('"') - PsiWhiteSpace(' ') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - PsiWhiteSpace(' ') - BLOCK - DOT_QUALIFIED_EXPRESSION - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('B') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('String') - PsiElement(GT)('>') - PsiElement(DOT)('.') - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PARENTHESIZED - PsiElement(LPAR)('(') - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_EXPRESSION - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Boolean') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - BOOLEAN_CONSTANT - PsiElement(true)('true') - PsiElement(RPAR)(')') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace(' ') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiElement(DOT)('.') - PsiElement(LPAR)('(') - PsiElement(IDENTIFIER)('x') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Any') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Unit') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL diff --git a/compiler/testData/psi/FunctionLiterals_ERR.kt b/compiler/testData/psi/FunctionLiterals_ERR.kt index a7ca216974b..1efe41c4736 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.kt +++ b/compiler/testData/psi/FunctionLiterals_ERR.kt @@ -27,4 +27,31 @@ fun foo() { {T.(a, b) } {(a: Int, )} {a, } + + {(a) -> a} + {(a : A) -> a} + + {(a : A) : T -> a} + {(a) : T -> a} + + {(a, a) -> a} + {(a : A, a : B) -> a} + {(a : A, a) : T -> a} + {(a, a : B) : T -> a} + + {() -> a} + {() -> a} + {() : T -> a} + {() : T -> a} + + {T.(a) -> a} + {T.(a : A) -> a} + {T.(a : A) : T -> a} + {T.(a) : T -> a} + + {@[a] x, @[b] y, @[c] z -> 1} + + {((a: Int = object { fun t() {} }) -> Int).(x: Int) : String -> "" } + { A.B.(x: Int) -> } + {((a: Boolean = true) -> Int).(x: Any) : Unit -> } } \ No newline at end of file diff --git a/compiler/testData/psi/FunctionLiterals_ERR.txt b/compiler/testData/psi/FunctionLiterals_ERR.txt index c4d74aa098b..9227af58835 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.txt +++ b/compiler/testData/psi/FunctionLiterals_ERR.txt @@ -50,19 +50,16 @@ JetFile: FunctionLiterals_ERR.kt BLOCK PARENTHESIZED PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - PsiErrorElement:Type expected - - PsiElement(RPAR)(')') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') @@ -72,56 +69,41 @@ JetFile: FunctionLiterals_ERR.kt FUNCTION_LITERAL PsiElement(LBRACE)('{') BLOCK - BINARY_EXPRESSION - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - PsiErrorElement:Type expected - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - OPERATION_REFERENCE + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiErrorElement:Expecting an element + PsiErrorElement:Expecting ')' + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') BLOCK - BINARY_WITH_TYPE - PARENTHESIZED - PsiElement(LPAR)('(') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') PsiElement(RBRACE)('}') @@ -152,20 +134,15 @@ JetFile: FunctionLiterals_ERR.kt BLOCK PARENTHESIZED PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiErrorElement:Expecting ')' + PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') PsiElement(COMMA)(',') PsiWhiteSpace(' ') PsiElement(COMMA)(',') @@ -188,20 +165,15 @@ JetFile: FunctionLiterals_ERR.kt BLOCK PARENTHESIZED PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiErrorElement:Expecting ')' + PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') PsiElement(COMMA)(',') PsiWhiteSpace(' ') PsiElement(COMMA)(',') @@ -260,20 +232,17 @@ JetFile: FunctionLiterals_ERR.kt PsiElement(MINUS)('-') PARENTHESIZED PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') @@ -368,63 +337,62 @@ JetFile: FunctionLiterals_ERR.kt FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') + PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiErrorElement:Expecting parameter name + + BLOCK + PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') - BLOCK - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') + PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE PsiErrorElement:Type expected - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiErrorElement:Expecting parameter name + + BLOCK + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') BLOCK - BINARY_WITH_TYPE - DOT_QUALIFIED_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('f') @@ -476,19 +444,14 @@ JetFile: FunctionLiterals_ERR.kt BLOCK PARENTHESIZED PsiElement(LPAR)('(') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') PsiErrorElement:Expecting ')' PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') PsiElement(COMMA)(',') PsiWhiteSpace(' ') PsiElement(RPAR)(')') @@ -508,5 +471,555 @@ JetFile: FunctionLiterals_ERR.kt BLOCK PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('B') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('B') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + ANNOTATED_EXPRESSION + ANNOTATION + PsiElement(AT)('@') + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(AT)('@') + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(AT)('@') + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('c') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('z') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BLOCK + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('t') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('String') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(OPEN_QUOTE)('"') + PsiElement(CLOSING_QUOTE)('"') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BLOCK + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('B') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PARENTHESIZED + PsiElement(LPAR)('(') + PARENTHESIZED + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(true)('true') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/IncompleteFunctionLiteral.kt b/compiler/testData/psi/IncompleteFunctionLiteral.kt new file mode 100644 index 00000000000..643b601fda8 --- /dev/null +++ b/compiler/testData/psi/IncompleteFunctionLiteral.kt @@ -0,0 +1,3 @@ +fun foo() { + {a: Int} +} \ No newline at end of file diff --git a/compiler/testData/psi/IncompleteFunctionLiteral.txt b/compiler/testData/psi/IncompleteFunctionLiteral.txt new file mode 100644 index 00000000000..d14e453c431 --- /dev/null +++ b/compiler/testData/psi/IncompleteFunctionLiteral.txt @@ -0,0 +1,35 @@ +JetFile: IncompleteFunctionLiteral.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiErrorElement:Expecting '->' or ',' + + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt index a072aead241..3a6379018fd 100644 --- a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt +++ b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt @@ -265,17 +265,13 @@ JetFile: TypeExpressionAmbiguities_ERR.kt PsiElement(COMMA)(',') PsiWhiteSpace(' ') VALUE_ARGUMENT - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected type specification + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('b') PsiElement(COMMA)(',') PsiWhiteSpace(' ') VALUE_ARGUMENT @@ -291,28 +287,17 @@ JetFile: TypeExpressionAmbiguities_ERR.kt PsiElement(RPAR)(')') PsiElement(RPAR)(')') PsiWhiteSpace('\n ') - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COLON)(':') PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('b') PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiWhiteSpace(' ') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') - PsiErrorElement:Expecting a '>' - + PsiElement(LT)('<') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('c') PsiWhiteSpace('\n ') BINARY_WITH_TYPE REFERENCE_EXPRESSION @@ -360,4 +345,4 @@ JetFile: TypeExpressionAmbiguities_ERR.kt PsiErrorElement:Expecting a '>' PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/primaryConstructor/recovery.txt b/compiler/testData/psi/primaryConstructor/recovery.txt index 4b501590c3d..6f5a136e53e 100644 --- a/compiler/testData/psi/primaryConstructor/recovery.txt +++ b/compiler/testData/psi/primaryConstructor/recovery.txt @@ -21,16 +21,12 @@ JetFile: recovery.kt VALUE_ARGUMENT_LIST PsiElement(LPAR)('(') VALUE_ARGUMENT - BINARY_WITH_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') - OPERATION_REFERENCE - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiErrorElement:Unexpected type specification + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') PsiElement(RPAR)(')') PsiErrorElement:Expecting 'constructor' keyword diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 9385a027905..53381e5f441 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -451,6 +451,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("IncompleteFunctionLiteral.kt") + public void testIncompleteFunctionLiteral() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/IncompleteFunctionLiteral.kt"); + doParsingTest(fileName); + } + @TestMetadata("Inner.kt") public void testInner() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Inner.kt");