diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index a2da39aa56e..6c6191294d8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -1494,7 +1494,7 @@ public class JetExpressionParsing extends AbstractJetParsing { PsiBuilder.Marker parameters = mark(); expect(LPAR, "Expecting '('", recoverySet); if (!atSet(recoverySet)) { - myJetParsing.parseValueParameter(); + myJetParsing.parseValueParameter(/*typeRequired = */ true); expect(RPAR, "Expecting ')'", recoverySet); } else { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index b2cec2f208c..4da0e233b22 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -639,7 +639,7 @@ public class JetParsing extends AbstractJetParsing { beforeConstructorModifiers.drop(); if (at(LPAR)) { - parseValueParameterList(false, TokenSet.create(COLON, LBRACE)); + parseValueParameterList(false, /* typeRequired = */ true, TokenSet.create(COLON, LBRACE)); } else if (hasConstructorModifiers) { // A comprehensive error message for cases like: @@ -1253,7 +1253,7 @@ public class JetParsing extends AbstractJetParsing { } if (at(LPAR)) { - parseValueParameterList(false, valueParametersFollow); + parseValueParameterList(false, /* typeRequired = */ false, valueParametersFollow); } else { error("Expecting '('"); @@ -1937,7 +1937,7 @@ public class JetParsing extends AbstractJetParsing { assert _at(LPAR) : tt(); PsiBuilder.Marker functionType = mark(); - parseValueParameterList(true, TokenSet.EMPTY); + parseValueParameterList(true, /* typeRequired = */ true, TokenSet.EMPTY); expect(ARROW, "Expecting '->' to specify return type of a function type", TYPE_REF_FIRST); parseTypeRef(); @@ -1958,7 +1958,7 @@ public class JetParsing extends AbstractJetParsing { * : parameter ("=" element)? * ; */ - void parseValueParameterList(boolean isFunctionTypeContents, TokenSet recoverySet) { + void parseValueParameterList(boolean isFunctionTypeContents, boolean typeRequired, TokenSet recoverySet) { assert _at(LPAR); PsiBuilder.Marker parameters = mark(); @@ -1976,7 +1976,7 @@ public class JetParsing extends AbstractJetParsing { } if (isFunctionTypeContents) { - if (!tryParseValueParameter()) { + if (!tryParseValueParameter(typeRequired)) { PsiBuilder.Marker valueParameter = mark(); parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); // lazy, out, ref parseTypeRef(); @@ -1984,7 +1984,7 @@ public class JetParsing extends AbstractJetParsing { } } else { - parseValueParameter(); + parseValueParameter(typeRequired); } if (at(COMMA)) { @@ -2008,15 +2008,15 @@ public class JetParsing extends AbstractJetParsing { * : modifiers ("val" | "var")? parameter ("=" element)? * ; */ - private boolean tryParseValueParameter() { - return parseValueParameter(true); + private boolean tryParseValueParameter(boolean typeRequired) { + return parseValueParameter(true, typeRequired); } - public void parseValueParameter() { - parseValueParameter(false); + public void parseValueParameter(boolean typeRequired) { + parseValueParameter(false, typeRequired); } - private boolean parseValueParameter(boolean rollbackOnFailure) { + private boolean parseValueParameter(boolean rollbackOnFailure, boolean typeRequired) { PsiBuilder.Marker parameter = mark(); parseModifierListWithShortAnnotations(MODIFIER_LIST, TokenSet.create(IDENTIFIER), TokenSet.create(COMMA, RPAR, COLON)); @@ -2025,7 +2025,7 @@ public class JetParsing extends AbstractJetParsing { advance(); // VAR_KEYWORD | VAL_KEYWORD } - if (!parseFunctionParameterRest() && rollbackOnFailure) { + if (!parseFunctionParameterRest(typeRequired) && rollbackOnFailure) { parameter.rollbackTo(); return false; } @@ -2039,7 +2039,7 @@ public class JetParsing extends AbstractJetParsing { * : parameter ("=" element)? * ; */ - private boolean parseFunctionParameterRest() { + private boolean parseFunctionParameterRest(boolean typeRequired) { boolean noErrors = true; // Recovery for the case 'fun foo(Array) {}' @@ -2055,7 +2055,7 @@ public class JetParsing extends AbstractJetParsing { advance(); // COLON parseTypeRef(); } - else { + else if (typeRequired) { errorWithRecovery("Parameters must have type annotation", PARAMETER_NAME_RECOVERY_SET); noErrors = false; } diff --git a/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt b/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt index 64f966f1d20..f5a48c1cf6f 100644 --- a/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt +++ b/compiler/testData/diagnostics/tests/FunctionParameterWithoutType.kt @@ -1,12 +1,11 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE - -fun test(a) { +fun test(a) { } class A(a) -val bar = fun test(a){} +val bar = fun test(a){} val la = { (a) -> } val las = { (a: Int) -> } \ No newline at end of file diff --git a/compiler/testData/psi/ParameterType.kt b/compiler/testData/psi/ParameterType.kt new file mode 100644 index 00000000000..dc873605dde --- /dev/null +++ b/compiler/testData/psi/ParameterType.kt @@ -0,0 +1,24 @@ +fun test1(a) {} +fun test2(a = 4) {} +fun test3(c: Int) {} + +fun test4(ann(parameter) a) {} +fun test5(ann a) {} + +fun test() { + try { + + } + catch(a: Int) { + + } +} + +val a = fun (b) {} +val a = fun (b = 4) {} +val a = fun (b: Int) {} + +val a: (A) -> Unit +val a: (a: A) -> Unit + +class A(a: Int) \ No newline at end of file diff --git a/compiler/testData/psi/ParameterType.txt b/compiler/testData/psi/ParameterType.txt new file mode 100644 index 00000000000..6244595cfcc --- /dev/null +++ b/compiler/testData/psi/ParameterType.txt @@ -0,0 +1,283 @@ +JetFile: ParameterType.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test1') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test2') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('4') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test3') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('c') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test4') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('parameter') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test5') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + TRY + PsiElement(try)('try') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + CATCH + PsiElement(catch)('catch') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('4') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') \ No newline at end of file diff --git a/compiler/testData/psi/ParameterType_ERR.kt b/compiler/testData/psi/ParameterType_ERR.kt new file mode 100644 index 00000000000..eab701c2c13 --- /dev/null +++ b/compiler/testData/psi/ParameterType_ERR.kt @@ -0,0 +1,25 @@ +fun test1(a:) {} + +fun foo(inlineOptions(InlineOp)) { } + +fun test2(ann(parameter) ) {} +fun test3(ann ) {} + +fun test() { + try { + + } + catch(a) { + + } + catch(a:) { + + } +} + +val a = fun (b:) {} + +val a: (a:) -> Unit + +class A(a) +class A(a:) \ No newline at end of file diff --git a/compiler/testData/psi/ParameterType_ERR.txt b/compiler/testData/psi/ParameterType_ERR.txt new file mode 100644 index 00000000000..de172ad2ff6 --- /dev/null +++ b/compiler/testData/psi/ParameterType_ERR.txt @@ -0,0 +1,223 @@ +JetFile: ParameterType_ERR.kt + PACKAGE_DIRECTIVE + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test1') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('inlineOptions') + PsiErrorElement:Expecting comma or ')' + + PsiErrorElement:Expecting ')' + PsiElement(LPAR)('(') + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('InlineOp') + PsiErrorElement:Expecting a top level declaration + PsiElement(RPAR)(')') + PsiErrorElement:Expecting a top level declaration + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a top level declaration + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a top level declaration + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test2') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('ann') + PsiErrorElement:Expecting comma or ')' + + PsiErrorElement:Expecting ')' + PsiElement(LPAR)('(') + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('parameter') + PsiErrorElement:Expecting a top level declaration + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a top level declaration + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a top level declaration + PsiElement(LBRACE)('{') + PsiErrorElement:Expecting a top level declaration + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test3') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('test') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + TRY + PsiElement(try)('try') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + CATCH + PsiElement(catch)('catch') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Parameters must have type annotation + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + CATCH + PsiElement(catch)('catch') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Parameters must have type annotation + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') \ No newline at end of file diff --git a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt index 7e9f14e7f5b..ca3f5fc9b63 100644 --- a/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt +++ b/compiler/testData/psi/platformTypesRecovery/WrongWordInParentheses.txt @@ -59,12 +59,12 @@ JetFile: WrongWordInParentheses.kt PsiWhiteSpace(' ') VALUE_PARAMETER PsiElement(IDENTIFIER)('Bar') - PsiErrorElement:Parameters must have type annotation - PsiElement(GT)('>') PsiErrorElement:Expecting comma or ')' PsiErrorElement:Expecting ')' - PsiElement(EXCL)('!') + PsiElement(GT)('>') + PsiErrorElement:Expecting a top level declaration + PsiElement(EXCL)('!') PsiWhiteSpace('\n') PsiErrorElement:Expecting a top level declaration PsiElement(RPAR)(')') diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 5f9cc246b1d..255e07588a5 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -465,6 +465,18 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("ParameterType.kt") + public void testParameterType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/ParameterType.kt"); + doParsingTest(fileName); + } + + @TestMetadata("ParameterType_ERR.kt") + public void testParameterType_ERR() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/ParameterType_ERR.kt"); + doParsingTest(fileName); + } + @TestMetadata("Precedence.kt") public void testPrecedence() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Precedence.kt"); diff --git a/idea/testData/completion/basic/common/annotations/ParameterAnnotation6.kt b/idea/testData/completion/basic/common/annotations/ParameterAnnotation6.kt index fa108725d8a..8475e4dee53 100644 --- a/idea/testData/completion/basic/common/annotations/ParameterAnnotation6.kt +++ b/idea/testData/completion/basic/common/annotations/ParameterAnnotation6.kt @@ -1,6 +1,6 @@ val v = 1 -fun foo(inlineOptions(InlineOp) { } +fun foo(inlineOptions(InlineOp) a: Int) { } // INVOCATION_COUNT: 1 // EXIST: InlineOption diff --git a/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.dump b/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.dump index a104dc8632b..55afe1e0ccd 100644 --- a/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.dump +++ b/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.dump @@ -1,6 +1,6 @@ Resolve target: null ---------------------------------------------- -fun foo(p: Any?, p1, Any?) { +fun foo(p: Any?, p1: Any?) { /* STATEMENT DELETED: if (x()) { y(p!!) } else { z(p1!!) } */ xxx diff --git a/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.kt b/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.kt index 48285c8f57a..07e5f639e1e 100644 --- a/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.kt +++ b/idea/testData/resolve/partialBodyResolve/IfBranchesAutoCasts.kt @@ -1,4 +1,4 @@ -fun foo(p: Any?, p1, Any?) { +fun foo(p: Any?, p1: Any?) { if (x()) { y(p!!) }