Exception fix: more accurate parsing of class base type #EA-65509 Fixed
This commit is contained in:
@@ -1844,6 +1844,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
IElementType lookahead = lookahead(1);
|
IElementType lookahead = lookahead(1);
|
||||||
IElementType lookahead2 = lookahead(2);
|
IElementType lookahead2 = lookahead(2);
|
||||||
|
boolean typeBeforeDot = true;
|
||||||
if (at(IDENTIFIER) && !(lookahead == DOT && lookahead2 == IDENTIFIER) && lookahead != LT && at(DYNAMIC_KEYWORD)) {
|
if (at(IDENTIFIER) && !(lookahead == DOT && lookahead2 == IDENTIFIER) && lookahead != LT && at(DYNAMIC_KEYWORD)) {
|
||||||
PsiBuilder.Marker dynamicType = mark();
|
PsiBuilder.Marker dynamicType = mark();
|
||||||
advance(); // DYNAMIC_KEYWORD
|
advance(); // DYNAMIC_KEYWORD
|
||||||
@@ -1892,12 +1893,14 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
else {
|
else {
|
||||||
errorWithRecovery("Type expected",
|
errorWithRecovery("Type expected",
|
||||||
TokenSet.orSet(TOP_LEVEL_DECLARATION_FIRST,
|
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);
|
typeRefMarker = parseNullableTypeSuffix(typeRefMarker);
|
||||||
|
|
||||||
if (at(DOT)) {
|
if (typeBeforeDot && at(DOT)) {
|
||||||
// This is a receiver for a function type
|
// This is a receiver for a function type
|
||||||
// A.(B) -> C
|
// A.(B) -> C
|
||||||
// ^
|
// ^
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// !DIAGNOSTICS: -FUNCTION_DECLARATION_WITH_NO_NAME
|
||||||
|
class ClassB() {
|
||||||
|
private inner class ClassC: <!SYNTAX!>super<!><!SYNTAX!>.<!><!UNRESOLVED_REFERENCE!>ClassA<!>()<!SYNTAX!><!> {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal final class ClassB {
|
||||||
|
public constructor ClassB()
|
||||||
|
[ERROR : ClassA]() internal final fun <no name provided>(): 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class ClassB() {
|
||||||
|
class ClassC: super.ClassA() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
JetFile: NonTypeBeforeDotInBaseClass.kt
|
||||||
|
PACKAGE_DIRECTIVE
|
||||||
|
<empty list>
|
||||||
|
IMPORT_LIST
|
||||||
|
<empty 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
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -10212,6 +10212,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("ea66984.kt")
|
||||||
public void testEa66984() throws Exception {
|
public void testEa66984() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/ea66984.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/ea66984.kt");
|
||||||
|
|||||||
@@ -487,6 +487,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
|||||||
doParsingTest(fileName);
|
doParsingTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NonTypeBeforeDotInBaseClass.kt")
|
||||||
|
public void testNonTypeBeforeDotInBaseClass() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/NonTypeBeforeDotInBaseClass.kt");
|
||||||
|
doParsingTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NotIsAndNotIn.kt")
|
@TestMetadata("NotIsAndNotIn.kt")
|
||||||
public void testNotIsAndNotIn() throws Exception {
|
public void testNotIsAndNotIn() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/NotIsAndNotIn.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/NotIsAndNotIn.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user