diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index 4617685b448..80fcc21612a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -1844,6 +1844,7 @@ public class JetParsing extends AbstractJetParsing { IElementType lookahead = lookahead(1); IElementType lookahead2 = lookahead(2); + boolean typeBeforeDot = true; if (at(IDENTIFIER) && !(lookahead == DOT && lookahead2 == IDENTIFIER) && lookahead != LT && at(DYNAMIC_KEYWORD)) { PsiBuilder.Marker dynamicType = mark(); advance(); // DYNAMIC_KEYWORD @@ -1892,12 +1893,14 @@ public class JetParsing extends AbstractJetParsing { else { errorWithRecovery("Type expected", TokenSet.orSet(TOP_LEVEL_DECLARATION_FIRST, - TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON), extraRecoverySet)); + TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON), + extraRecoverySet)); + typeBeforeDot = false; } typeRefMarker = parseNullableTypeSuffix(typeRefMarker); - if (at(DOT)) { + if (typeBeforeDot && at(DOT)) { // This is a receiver for a function type // A.(B) -> C // ^ diff --git a/compiler/testData/diagnostics/tests/regressions/ea65509.kt b/compiler/testData/diagnostics/tests/regressions/ea65509.kt new file mode 100644 index 00000000000..23451feb595 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/ea65509.kt @@ -0,0 +1,5 @@ +// !DIAGNOSTICS: -FUNCTION_DECLARATION_WITH_NO_NAME +class ClassB() { + private inner class ClassC: super.ClassA() { + } +} diff --git a/compiler/testData/diagnostics/tests/regressions/ea65509.txt b/compiler/testData/diagnostics/tests/regressions/ea65509.txt new file mode 100644 index 00000000000..5613a82dc6b --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/ea65509.txt @@ -0,0 +1,16 @@ +package + +internal final class ClassB { + public constructor ClassB() + [ERROR : ClassA]() internal final fun (): kotlin.Unit + 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 + + private final inner class ClassC { + public constructor ClassC() + 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 + } +} diff --git a/compiler/testData/psi/NonTypeBeforeDotInBaseClass.kt b/compiler/testData/psi/NonTypeBeforeDotInBaseClass.kt new file mode 100644 index 00000000000..71630fbbf8f --- /dev/null +++ b/compiler/testData/psi/NonTypeBeforeDotInBaseClass.kt @@ -0,0 +1,4 @@ +class ClassB() { + class ClassC: super.ClassA() { + } +} diff --git a/compiler/testData/psi/NonTypeBeforeDotInBaseClass.txt b/compiler/testData/psi/NonTypeBeforeDotInBaseClass.txt new file mode 100644 index 00000000000..8ddf2504a93 --- /dev/null +++ b/compiler/testData/psi/NonTypeBeforeDotInBaseClass.txt @@ -0,0 +1,50 @@ +JetFile: NonTypeBeforeDotInBaseClass.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ClassB') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ClassC') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + PsiErrorElement:Type expected + PsiElement(super)('super') + PsiErrorElement:Expecting member declaration + PsiElement(DOT)('.') + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ClassA') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting member declaration + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index c3fba608824..e4082fe9631 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10212,6 +10212,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("ea65509.kt") + public void testEa65509() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/ea65509.kt"); + doTest(fileName); + } + @TestMetadata("ea66984.kt") public void testEa66984() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/ea66984.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index b39205bcfa4..a9abc6588af 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -487,6 +487,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("NonTypeBeforeDotInBaseClass.kt") + public void testNonTypeBeforeDotInBaseClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/NonTypeBeforeDotInBaseClass.kt"); + doParsingTest(fileName); + } + @TestMetadata("NotIsAndNotIn.kt") public void testNotIsAndNotIn() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/NotIsAndNotIn.kt");