Add recovery for enum declaration without 'class' keyword
^KT-13703 Fixed
This commit is contained in:
@@ -119,7 +119,7 @@ class IllegalModifiers7() {
|
||||
// Secondary constructors
|
||||
class IllegalModifiers8 {
|
||||
<!WRONG_MODIFIER_TARGET!>abstract<!>
|
||||
<!WRONG_MODIFIER_TARGET!>enum<!>
|
||||
enum
|
||||
<!REDUNDANT_MODIFIER, WRONG_MODIFIER_TARGET!>open<!>
|
||||
<!WRONG_MODIFIER_TARGET!>inner<!>
|
||||
<!WRONG_MODIFIER_TARGET!>annotation<!>
|
||||
@@ -129,7 +129,7 @@ class IllegalModifiers8 {
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!>
|
||||
<!WRONG_MODIFIER_TARGET!>vararg<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>const<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>const<!><!SYNTAX!><!>
|
||||
constructor() {}
|
||||
|
||||
constructor(<!WRONG_MODIFIER_TARGET!>private<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!INCOMPATIBLE_MODIFIERS!>abstract<!> <!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
|
||||
@@ -108,11 +108,27 @@ package illegal_modifiers {
|
||||
}
|
||||
|
||||
public final class IllegalModifiers8 {
|
||||
public constructor IllegalModifiers8()
|
||||
public constructor IllegalModifiers8(/*0*/ x: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public abstract enum class constructor : kotlin.Enum<illegal_modifiers.IllegalModifiers8.constructor> {
|
||||
private constructor constructor()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: illegal_modifiers.IllegalModifiers8.constructor): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<illegal_modifiers.IllegalModifiers8.constructor!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): illegal_modifiers.IllegalModifiers8.constructor
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<illegal_modifiers.IllegalModifiers8.constructor>
|
||||
}
|
||||
}
|
||||
|
||||
public final class IllegalModifiers9 {
|
||||
|
||||
+12
-13
@@ -23,21 +23,20 @@ KtFile: EnumWithAnnotationKeyword.kt
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
MODIFIER_LIST
|
||||
PsiElement(enum)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(annotation)('annotation')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
PsiElement(IDENTIFIER)('E1')
|
||||
PsiWhiteSpace(' ')
|
||||
FUN
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
CLASS
|
||||
MODIFIER_LIST
|
||||
PsiElement(enum)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(annotation)('annotation')
|
||||
PsiErrorElement:'class' keyword is expected after 'enum'
|
||||
<empty list>
|
||||
BLOCK
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('E1')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
REFERENCE_EXPRESSION
|
||||
ENUM_ENTRY
|
||||
PsiElement(IDENTIFIER)('D')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiElement(RBRACE)('}')
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
enum A { X, Y }
|
||||
|
||||
private enum B {
|
||||
X, Y
|
||||
}
|
||||
|
||||
internal Q {
|
||||
X, Y
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
// No recovery here
|
||||
enum A { X, Y }
|
||||
|
||||
private enum B {
|
||||
X, Y
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
KtFile: enumWthoutClass.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
CLASS
|
||||
MODIFIER_LIST
|
||||
PsiElement(enum)('enum')
|
||||
PsiErrorElement:'class' keyword is expected after 'enum'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('A')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
ENUM_ENTRY
|
||||
PsiElement(IDENTIFIER)('X')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
ENUM_ENTRY
|
||||
PsiElement(IDENTIFIER)('Y')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
CLASS
|
||||
MODIFIER_LIST
|
||||
PsiElement(private)('private')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(enum)('enum')
|
||||
PsiErrorElement:'class' keyword is expected after 'enum'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('B')
|
||||
PsiWhiteSpace(' ')
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
ENUM_ENTRY
|
||||
PsiElement(IDENTIFIER)('X')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
ENUM_ENTRY
|
||||
PsiElement(IDENTIFIER)('Y')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
MODIFIER_LIST
|
||||
PsiElement(internal)('internal')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
PsiElement(IDENTIFIER)('Q')
|
||||
PsiWhiteSpace(' ')
|
||||
FUN
|
||||
PsiErrorElement:Expecting a top level declaration
|
||||
<empty list>
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('X')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('Y')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('foo')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiComment(EOL_COMMENT)('// No recovery here')
|
||||
PsiWhiteSpace('\n ')
|
||||
BINARY_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(IDENTIFIER)('A')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER_LIST
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('X')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('Y')
|
||||
PsiErrorElement:Expecting '->' or ','
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
<empty list>
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
BINARY_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('private')
|
||||
PsiWhiteSpace(' ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(IDENTIFIER)('enum')
|
||||
PsiWhiteSpace(' ')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('B')
|
||||
PsiWhiteSpace(' ')
|
||||
LAMBDA_ARGUMENT
|
||||
LAMBDA_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
VALUE_PARAMETER_LIST
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('X')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('Y')
|
||||
PsiErrorElement:Expecting '->' or ','
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
BLOCK
|
||||
<empty list>
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
Reference in New Issue
Block a user