diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/AbstractJetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/AbstractJetParsing.java index 1d8862f7bd3..826e37cbf6d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/AbstractJetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/AbstractJetParsing.java @@ -113,9 +113,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*; protected boolean errorAndAdvance(String message, int advanceTokenCount) { PsiBuilder.Marker err = mark(); - for (int i = 0; i < advanceTokenCount; i++) { - advance(); // erroneous token - } + advance(advanceTokenCount); err.error(message); return false; } @@ -129,6 +127,12 @@ import static org.jetbrains.jet.lexer.JetTokens.*; myBuilder.advanceLexer(); } + protected void advance(int advanceTokenCount) { + for (int i = 0; i < advanceTokenCount; i++) { + advance(); // erroneous token + } + } + protected void advanceAt(IElementType current) { assert _at(current); myBuilder.advanceLexer(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 896b6ea35b2..6704ec01e54 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -1488,7 +1488,7 @@ public class JetParsing extends AbstractJetParsing { PsiBuilder.Marker typeRefMarker = mark(); parseAnnotations(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); - if (at(IDENTIFIER) || at(PACKAGE_KEYWORD)) { + if (at(IDENTIFIER) || at(PACKAGE_KEYWORD) || atParenthesizedMutableForPlatformTypes(0)) { parseUserType(); } else if (at(HASH)) { @@ -1577,6 +1577,11 @@ public class JetParsing extends AbstractJetParsing { * userType * : ("package" ".")? simpleUserType{"."} * ; + * + * recovers on platform types: + * - Foo! + * - (Mutable)List! + * - Array<(out) Foo>! */ void parseUserType() { PsiBuilder.Marker userType = mark(); @@ -1588,6 +1593,8 @@ public class JetParsing extends AbstractJetParsing { PsiBuilder.Marker reference = mark(); while (true) { + recoverOnParenthesizedWordForPlatformTypes(0, "Mutable", true); + if (expect(IDENTIFIER, "Expecting type name", TokenSet.orSet(JetExpressionParsing.EXPRESSION_FIRST, JetExpressionParsing.EXPRESSION_FOLLOW))) { reference.done(REFERENCE_EXPRESSION); @@ -1598,10 +1605,13 @@ public class JetParsing extends AbstractJetParsing { } parseTypeArgumentList(); + + recoverOnPlatformTypeSuffix(); + if (!at(DOT)) { break; } - if (lookahead(1) == LPAR) { + if (lookahead(1) == LPAR && !atParenthesizedMutableForPlatformTypes(1)) { // This may be a receiver for a function type // Int.(Int) -> Int break; @@ -1618,6 +1628,49 @@ public class JetParsing extends AbstractJetParsing { userType.done(USER_TYPE); } + private boolean atParenthesizedMutableForPlatformTypes(int offset) { + return recoverOnParenthesizedWordForPlatformTypes(offset, "Mutable", false); + } + + private boolean recoverOnParenthesizedWordForPlatformTypes(int offset, String word, boolean consume) { + // Array<(out) Foo>! or (Mutable)List! + if (lookahead(offset) == LPAR && lookahead(offset + 1) == IDENTIFIER && lookahead(offset + 2) == RPAR && lookahead(offset + 3) == IDENTIFIER) { + PsiBuilder.Marker error = mark(); + + advance(offset); + + advance(); // LPAR + if (!word.equals(myBuilder.getTokenText())) { + // something other than "out" / "Mutable" + error.rollbackTo(); + return false; + } + else { + advance(); // IDENTIFIER('out') + advance(); // RPAR + + if (consume) { + error.error("Unexpected tokens"); + } + else { + error.rollbackTo(); + } + + return true; + } + } + return false; + } + + private void recoverOnPlatformTypeSuffix() { + // Recovery for platform types + if (at(EXCL)) { + PsiBuilder.Marker error = mark(); + advance(); // EXCL + error.error("Unexpected token"); + } + } + /* * selfType * : "This" @@ -1652,6 +1705,8 @@ public class JetParsing extends AbstractJetParsing { while (true) { PsiBuilder.Marker projection = mark(); + recoverOnParenthesizedWordForPlatformTypes(0, "out", true); + // TokenSet lookFor = TokenSet.create(IDENTIFIER); // TokenSet stopAt = TokenSet.create(COMMA, COLON, GT); // parseModifierListWithShortAnnotations(MODIFIER_LIST, lookFor, stopAt); diff --git a/compiler/testData/psi/platformTypesRecovery/Array.kt b/compiler/testData/psi/platformTypesRecovery/Array.kt new file mode 100644 index 00000000000..a6d678af651 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Array.kt @@ -0,0 +1,5 @@ +fun foo( + p: Array<(out) Foo>!, + p1: Array<(out) Foo!>!, + p1: Array<(out) Array<(out) Foo>!>! +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Array.txt b/compiler/testData/psi/platformTypesRecovery/Array.txt new file mode 100644 index 00000000000..853b060f588 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Array.txt @@ -0,0 +1,106 @@ +JetFile: Array.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/BeforeDot.kt b/compiler/testData/psi/platformTypesRecovery/BeforeDot.kt new file mode 100644 index 00000000000..c4180227c8f --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/BeforeDot.kt @@ -0,0 +1,5 @@ +fun foo( + p: Foo!.Bar, + p: Foo!.Baz, + p1: Foo!.() -> Unit +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/BeforeDot.txt b/compiler/testData/psi/platformTypesRecovery/BeforeDot.txt new file mode 100644 index 00000000000..80770ad8147 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/BeforeDot.txt @@ -0,0 +1,80 @@ +JetFile: BeforeDot.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Baz') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + FUNCTION_TYPE_RECEIVER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Collections.kt b/compiler/testData/psi/platformTypesRecovery/Collections.kt new file mode 100644 index 00000000000..73861dcee46 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Collections.kt @@ -0,0 +1,6 @@ +fun foo( + p: (Mutable)List!, + p1: (Mutable)Iterable!, + p2: Foo<(Mutable)List!>, + p3: (Mutable)Set<(Mutable)List!> +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Collections.txt b/compiler/testData/psi/platformTypesRecovery/Collections.txt new file mode 100644 index 00000000000..d716b659803 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Collections.txt @@ -0,0 +1,134 @@ +JetFile: Collections.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p3') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Set') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.kt b/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.kt new file mode 100644 index 00000000000..01541686cda --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.kt @@ -0,0 +1,4 @@ +fun foo(f: (Mutable) -> Unit) {} +fun foo(f: T.(Mutable) -> Unit) {} +fun foo(f: Array<(out) -> Unit>) {} +fun foo(f: Array Unit>) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.txt b/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.txt new file mode 100644 index 00000000000..4fbc91ca6b5 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.txt @@ -0,0 +1,164 @@ +JetFile: FunctionsNotPlatform.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + FUNCTION_TYPE_RECEIVER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + FUNCTION_TYPE + FUNCTION_TYPE_RECEIVER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/MapEntry.kt b/compiler/testData/psi/platformTypesRecovery/MapEntry.kt new file mode 100644 index 00000000000..aee2490e138 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/MapEntry.kt @@ -0,0 +1,4 @@ +fun foo( + p: (Mutable)Map.(Mutable)Entry!, + p: kotlin.(Mutable)Map.(Mutable)Entry!, +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/MapEntry.txt b/compiler/testData/psi/platformTypesRecovery/MapEntry.txt new file mode 100644 index 00000000000..613b22d7ce6 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/MapEntry.txt @@ -0,0 +1,103 @@ +JetFile: MapEntry.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Map') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Entry') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Map') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Entry') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiErrorElement:Expecting a parameter declaration + + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.kt b/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.kt new file mode 100644 index 00000000000..3090af73010 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.kt @@ -0,0 +1,2 @@ +fun foo(f: (Mutable)) {} +fun foo(f: Array<(out)>) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.txt b/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.txt new file mode 100644 index 00000000000..9aace22e624 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.txt @@ -0,0 +1,54 @@ +JetFile: ParenthesizedNotPlatform.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiElement(LPAR)('(') + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + PsiElement(LPAR)('(') + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Qualified.kt b/compiler/testData/psi/platformTypesRecovery/Qualified.kt new file mode 100644 index 00000000000..421b372dc19 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Qualified.kt @@ -0,0 +1,5 @@ +fun foo( + p: qualified.Type!, + p1: qualified.Foo, + p2: qualified.Foo! +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Qualified.txt b/compiler/testData/psi/platformTypesRecovery/Qualified.txt new file mode 100644 index 00000000000..b2e592474d6 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Qualified.txt @@ -0,0 +1,99 @@ +JetFile: Qualified.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('qualified') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.kt b/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.kt new file mode 100644 index 00000000000..662be3314d6 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.kt @@ -0,0 +1,6 @@ +fun foo( + p: kotlin.(Mutable)List!, + p1: kotlin.(Mutable)Iterable!, + p2: Foo!>, + p2: kotlin.(Mutable)Set!> +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.txt b/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.txt new file mode 100644 index 00000000000..766cfb15f88 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/QualifiedCollections.txt @@ -0,0 +1,154 @@ +JetFile: QualifiedCollections.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('Set') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('kotlin') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiErrorElement:Unexpected tokens + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('Mutable') + PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Simple.kt b/compiler/testData/psi/platformTypesRecovery/Simple.kt new file mode 100644 index 00000000000..2c69d421143 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Simple.kt @@ -0,0 +1,5 @@ +fun foo( + p: Type!, + p1: Foo, + p2: Foo! +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/Simple.txt b/compiler/testData/psi/platformTypesRecovery/Simple.txt new file mode 100644 index 00000000000..053901e4d11 --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/Simple.txt @@ -0,0 +1,75 @@ +JetFile: Simple.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Type') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.kt b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.kt new file mode 100644 index 00000000000..3b15745ecac --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.kt @@ -0,0 +1,4 @@ +fun foo( + p: (Foo)List!, + p1: Array<(foo) Bar>! +) {} \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt new file mode 100644 index 00000000000..431c4ee0e9f --- /dev/null +++ b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt @@ -0,0 +1,75 @@ +JetFile: WrongWordInParentheses.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiElement(LPAR)('(') + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Foo') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting comma or ')' + + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiElement(GT)('>') + PsiErrorElement:Unexpected token + PsiElement(EXCL)('!') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('p1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Array') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + PsiElement(LPAR)('(') + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(RPAR)(')') + PsiErrorElement:Expecting a '>' + + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('Bar') + PsiErrorElement:Parameters must have type annotation + PsiElement(GT)('>') + PsiErrorElement:Expecting comma or ')' + + PsiErrorElement:Expecting ')' + PsiElement(EXCL)('!') + PsiWhiteSpace('\n') + PsiErrorElement:Expecting package directive or top level declaration + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting package directive or top level declaration + PsiElement(LBRACE)('{') + PsiErrorElement:Expecting package directive or top level declaration + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java index 1a810392adc..a9b58559223 100644 --- a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java @@ -35,7 +35,7 @@ import java.util.regex.Pattern; public class JetParsingTestGenerated extends AbstractJetParsingTest { @TestMetadata("compiler/testData/psi") @TestDataPath("$PROJECT_ROOT") - @InnerTestClasses({Psi.Annotation.class, Psi.Examples.class, Psi.FunctionReceivers.class, Psi.GreatSyntacticShift.class, Psi.Kdoc.class, Psi.PropertyDelegate.class, Psi.Recovery.class, Psi.Script.class, Psi.StringTemplates.class}) + @InnerTestClasses({Psi.Annotation.class, Psi.Examples.class, Psi.FunctionReceivers.class, Psi.GreatSyntacticShift.class, Psi.Kdoc.class, Psi.PlatformTypesRecovery.class, Psi.PropertyDelegate.class, Psi.Recovery.class, Psi.Script.class, Psi.StringTemplates.class}) @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) public static class Psi extends AbstractJetParsingTest { @TestMetadata("AbsentInnerType.kt") @@ -1028,6 +1028,76 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { } + @TestMetadata("compiler/testData/psi/platformTypesRecovery") + @TestDataPath("$PROJECT_ROOT") + @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class) + public static class PlatformTypesRecovery extends AbstractJetParsingTest { + public void testAllFilesPresentInPlatformTypesRecovery() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/platformTypesRecovery"), Pattern.compile("^(.*)\\.kts?$"), true); + } + + @TestMetadata("Array.kt") + public void testArray() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/Array.kt"); + doParsingTest(fileName); + } + + @TestMetadata("BeforeDot.kt") + public void testBeforeDot() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/BeforeDot.kt"); + doParsingTest(fileName); + } + + @TestMetadata("Collections.kt") + public void testCollections() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/Collections.kt"); + doParsingTest(fileName); + } + + @TestMetadata("FunctionsNotPlatform.kt") + public void testFunctionsNotPlatform() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/FunctionsNotPlatform.kt"); + doParsingTest(fileName); + } + + @TestMetadata("MapEntry.kt") + public void testMapEntry() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/MapEntry.kt"); + doParsingTest(fileName); + } + + @TestMetadata("ParenthesizedNotPlatform.kt") + public void testParenthesizedNotPlatform() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/ParenthesizedNotPlatform.kt"); + doParsingTest(fileName); + } + + @TestMetadata("Qualified.kt") + public void testQualified() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/Qualified.kt"); + doParsingTest(fileName); + } + + @TestMetadata("QualifiedCollections.kt") + public void testQualifiedCollections() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/QualifiedCollections.kt"); + doParsingTest(fileName); + } + + @TestMetadata("Simple.kt") + public void testSimple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/Simple.kt"); + doParsingTest(fileName); + } + + @TestMetadata("WrongWordInParentheses.kt") + public void testWrongWordInParentheses() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.kt"); + doParsingTest(fileName); + } + + } + @TestMetadata("compiler/testData/psi/propertyDelegate") @TestDataPath("$PROJECT_ROOT") @RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)