diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index 22b92e98bf7..955efa65569 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -1279,7 +1279,9 @@ public class KotlinParsing extends AbstractKotlinParsing { if (!atSet(EOL_OR_SEMICOLON, RBRACE)) { if (getLastToken() != SEMICOLON) { - errorUntil("Property getter or setter expected", TokenSet.create(EOL_OR_SEMICOLON, LBRACE, RBRACE)); + errorUntil( + "Property getter or setter expected", + TokenSet.orSet(DECLARATION_FIRST, TokenSet.create(EOL_OR_SEMICOLON, LBRACE, RBRACE))); } } else { diff --git a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.kt b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.kt index d622c23d66c..0b315e01230 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.kt @@ -10,4 +10,6 @@ abstract class A { private val fun foo3() { } + + private val private fun foo() {} } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.txt b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.txt index 5529fe20409..c6ad2a16d67 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.txt +++ b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameBeforeNextDeclarationWithModifiers.txt @@ -5,7 +5,9 @@ public abstract class A { private final val : [ERROR : No type, no body] private final val : [ERROR : No type, no body] private final val : [ERROR : No type, no body] + private final val private: [ERROR : No type, no body] public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit private final fun foo1(): kotlin.Unit protected abstract fun foo2(): kotlin.Unit public final fun foo3(): kotlin.Unit diff --git a/compiler/testData/psi/DefaultKeyword.txt b/compiler/testData/psi/DefaultKeyword.txt index 09b92129526..3133228c96d 100644 --- a/compiler/testData/psi/DefaultKeyword.txt +++ b/compiler/testData/psi/DefaultKeyword.txt @@ -293,14 +293,15 @@ JetFile: DefaultKeyword.kt PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('companion') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(object)('object') - PsiWhiteSpace(' ') - FUN - PsiErrorElement:Expecting a top level declaration - BLOCK + PsiWhiteSpace(' ') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiErrorElement:Name expected + + PsiWhiteSpace(' ') + CLASS_BODY PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n') PsiElement(RBRACE)('}') diff --git a/compiler/testData/psi/FunctionExpressions_ERR.txt b/compiler/testData/psi/FunctionExpressions_ERR.txt index 73c89a739ca..579b0736da5 100644 --- a/compiler/testData/psi/FunctionExpressions_ERR.txt +++ b/compiler/testData/psi/FunctionExpressions_ERR.txt @@ -384,10 +384,13 @@ JetFile: FunctionExpressions_ERR.kt PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('public') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(fun)('fun') - PsiWhiteSpace(' ') + + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -400,10 +403,13 @@ JetFile: FunctionExpressions_ERR.kt PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('open') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(fun)('fun') - PsiWhiteSpace(' ') + + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -416,10 +422,13 @@ JetFile: FunctionExpressions_ERR.kt PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('final') - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(fun)('fun') - PsiWhiteSpace(' ') + + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -647,4 +656,4 @@ JetFile: FunctionExpressions_ERR.kt PsiElement(IDENTIFIER)('V') PsiElement(RPAR)(')') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/TypealiasIsKeyword.txt b/compiler/testData/psi/TypealiasIsKeyword.txt index 0ee571b708e..5b062100c13 100644 --- a/compiler/testData/psi/TypealiasIsKeyword.txt +++ b/compiler/testData/psi/TypealiasIsKeyword.txt @@ -7,10 +7,16 @@ JetFile: TypealiasIsKeyword.kt PsiElement(val)('val') PsiErrorElement:Expecting property name or receiver type - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(typealias)('typealias') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - PsiElement(INTEGER_LITERAL)('0') \ No newline at end of file + + PsiWhiteSpace(' ') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiErrorElement:Type name expected + + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + PsiElement(INTEGER_LITERAL)('0') \ No newline at end of file diff --git a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt index e616c7c36e2..a103fb39e63 100644 --- a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt +++ b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt @@ -278,21 +278,41 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt PsiElement(val)('val') PsiErrorElement:Expecting property name or receiver type - PsiWhiteSpace(' ') PsiErrorElement:Property getter or setter expected - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('T') - PsiElement(LT)('<') - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiErrorElement:Receiver type is not allowed on a destructuring declaration + TYPE_REFERENCE + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') PsiElement(DOT)('.') + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') - PsiElement(IDENTIFIER)('A') - PsiElement(LT)('<') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('A') + PsiErrorElement:Expecting ')' + PsiElement(LT)('<') + PsiErrorElement:Property getter or setter expected PsiElement(IDENTIFIER)('B') PsiElement(GT)('>') PsiElement(RPAR)(')') @@ -433,4 +453,4 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('A') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('B') + PsiElement(IDENTIFIER)('B') \ No newline at end of file