Parse type arguments after callable reference as error
Is likely to be supported in the future
This commit is contained in:
@@ -370,7 +370,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
|
||||
/*
|
||||
* callableReference
|
||||
* : (userType "?"*)? "::" SimpleName
|
||||
* : (userType "?"*)? "::" SimpleName typeArguments?
|
||||
* ;
|
||||
*/
|
||||
private boolean parseDoubleColonExpression() {
|
||||
@@ -396,6 +396,17 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
}
|
||||
else {
|
||||
parseSimpleNameExpression();
|
||||
|
||||
if (at(LT)) {
|
||||
PsiBuilder.Marker typeArgumentList = mark();
|
||||
if (myJetParsing.tryParseTypeArgumentList(TYPE_ARGUMENT_LIST_STOPPERS)) {
|
||||
typeArgumentList.error("Type arguments are not allowed");
|
||||
}
|
||||
else {
|
||||
typeArgumentList.rollbackTo();
|
||||
}
|
||||
}
|
||||
|
||||
expression.done(CALLABLE_REFERENCE_EXPRESSION);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
@@ -50,3 +50,11 @@ fun err2() {
|
||||
fun err3() {
|
||||
::
|
||||
}
|
||||
|
||||
fun typeArgumentsError() {
|
||||
::a<b>
|
||||
::a<b,c<*>>
|
||||
a::b<c>
|
||||
|
||||
::a<b>()
|
||||
}
|
||||
|
||||
+83
@@ -609,3 +609,86 @@ JetFile: DoubleColon.kt
|
||||
PsiErrorElement:Expecting an identifier
|
||||
<empty list>
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('typeArgumentsError')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
CALLABLE_REFERENCE_EXPRESSION
|
||||
PsiElement(COLONCOLON)('::')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiErrorElement:Type arguments are not allowed
|
||||
PsiElement(LT)('<')
|
||||
TYPE_PROJECTION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiElement(GT)('>')
|
||||
PsiWhiteSpace('\n ')
|
||||
CALLABLE_REFERENCE_EXPRESSION
|
||||
PsiElement(COLONCOLON)('::')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiErrorElement:Type arguments are not allowed
|
||||
PsiElement(LT)('<')
|
||||
TYPE_PROJECTION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiElement(COMMA)(',')
|
||||
TYPE_PROJECTION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
TYPE_ARGUMENT_LIST
|
||||
PsiElement(LT)('<')
|
||||
TYPE_PROJECTION
|
||||
PsiElement(MUL)('*')
|
||||
PsiElement(GT)('>')
|
||||
PsiElement(GT)('>')
|
||||
PsiWhiteSpace('\n ')
|
||||
CALLABLE_REFERENCE_EXPRESSION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiElement(COLONCOLON)('::')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiErrorElement:Type arguments are not allowed
|
||||
PsiElement(LT)('<')
|
||||
TYPE_PROJECTION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('c')
|
||||
PsiElement(GT)('>')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
CALLABLE_REFERENCE_EXPRESSION
|
||||
PsiElement(COLONCOLON)('::')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiErrorElement:Type arguments are not allowed
|
||||
PsiElement(LT)('<')
|
||||
TYPE_PROJECTION
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('b')
|
||||
PsiElement(GT)('>')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -104,7 +104,7 @@ postfixUnaryExpression
|
||||
|
||||
// TODO: callSuffix is forbidden after callableReference, since parentheses will be used to provide parameter types
|
||||
callableReference
|
||||
: (userType "?"*)? "::" SimpleName
|
||||
: (userType "?"*)? "::" SimpleName typeArguments?
|
||||
;
|
||||
|
||||
// !!! When you add here, remember to update the FIRST set in the parser
|
||||
|
||||
Reference in New Issue
Block a user