KT-1019 parser should recover from missing parentheses in function declaration
#KT-1019 Fixed
This commit is contained in:
@@ -1042,7 +1042,12 @@ public class JetParsing extends AbstractJetParsing {
|
||||
typeParameterListOccurred = true;
|
||||
}
|
||||
|
||||
parseValueParameterList(false, valueParametersFollow);
|
||||
if (at(LPAR)) {
|
||||
parseValueParameterList(false, valueParametersFollow);
|
||||
}
|
||||
else {
|
||||
error("Expecting '('");
|
||||
}
|
||||
|
||||
if (at(COLON)) {
|
||||
advance(); // COLON
|
||||
@@ -1648,10 +1653,11 @@ public class JetParsing extends AbstractJetParsing {
|
||||
* ;
|
||||
*/
|
||||
void parseValueParameterList(boolean isFunctionTypeContents, TokenSet recoverySet) {
|
||||
assert _at(LPAR);
|
||||
PsiBuilder.Marker parameters = mark();
|
||||
|
||||
myBuilder.disableNewlines();
|
||||
expect(LPAR, "Expecting '(", recoverySet);
|
||||
advance(); // LPAR
|
||||
|
||||
if (!parseIdeTemplate()) {
|
||||
if (!at(RPAR) && !atSet(recoverySet)) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
fun<!SYNTAX, SYNTAX, SYNTAX, SYNTAX, SYNTAX!><!>
|
||||
fun<!SYNTAX, SYNTAX!><!>
|
||||
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
fun foo
|
||||
class B {}
|
||||
fun bar
|
||||
}
|
||||
class C {}
|
||||
@@ -0,0 +1,50 @@
|
||||
JetFile: FunctionNoParameterList.kt
|
||||
NAMESPACE_HEADER
|
||||
<empty list>
|
||||
CLASS
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('A')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
PsiErrorElement:Expecting '('
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
CLASS
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('B')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('bar')
|
||||
PsiErrorElement:Expecting '('
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
CLASS
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('C')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_PARAMETER_LIST
|
||||
<empty list>
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -1,5 +1,4 @@
|
||||
fun foo)
|
||||
fun [a] f foo()
|
||||
fun [a] T.foo(a : ) : bar
|
||||
fun [a()] T.foo<>(a : foo) : bar
|
||||
fun [a()] T.foo<T, , T>(a : foo) : bar
|
||||
|
||||
@@ -5,35 +5,10 @@ JetFile: Functions_ERR.jet
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiErrorElement:Expecting '(
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
ANNOTATION
|
||||
PsiElement(LBRACKET)('[')
|
||||
ANNOTATION_ENTRY
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('a')
|
||||
PsiElement(RBRACKET)(']')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiErrorElement:Expecting '(
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER
|
||||
PsiErrorElement:Parameter name expected
|
||||
PsiElement(LPAR)('(')
|
||||
PsiErrorElement:Parameters must have type annotation
|
||||
<empty list>
|
||||
PsiElement(RPAR)(')')
|
||||
PsiErrorElement:Expecting '('
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting package directive or top level declaration
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
|
||||
Reference in New Issue
Block a user