From 62d204f4d627e17abe7dfedb9ce3b30924077b5d Mon Sep 17 00:00:00 2001 From: "victor.petukhov" Date: Mon, 7 Oct 2019 13:21:25 +0300 Subject: [PATCH] Support trailing comma ^KT-34743 Fixed --- .../resolve/PlatformConfiguratorBase.kt | 5 +- .../jetbrains/kotlin/resolve/TypeResolver.kt | 7 + .../resolve/checkers/TrailingCommaChecker.kt | 86 + .../ControlStructureTypingVisitor.java | 8 + .../DestructuringDeclarationResolver.kt | 3 + .../expressions/FunctionsTypingVisitor.kt | 7 + .../parsing/KotlinExpressionParsing.java | 19 +- .../kotlin/parsing/KotlinParsing.java | 15 +- .../kotlin/psi/KtArrayAccessExpression.java | 5 + .../psi/KtCollectionLiteralExpression.kt | 4 + .../psi/KtDestructuringDeclaration.java | 6 + .../jetbrains/kotlin/psi/KtParameterList.java | 11 + .../kotlin/psi/KtTypeArgumentList.java | 8 + .../kotlin/psi/KtTypeParameterList.java | 8 + .../kotlin/psi/KtValueArgumentList.java | 5 + .../org/jetbrains/kotlin/psi/KtWhenEntry.java | 5 + .../jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt | 11 + .../box/trailingComma/noDisambiguation.kt | 10 + .../tests/inference/regressions/kt2057.kt | 4 +- .../diagnostics/tests/variance/InPosition.kt | 2 +- .../diagnostics/tests/variance/InPosition.txt | 2 +- .../tests/variance/InvariantPosition.kt | 2 +- .../tests/variance/InvariantPosition.txt | 2 +- .../diagnostics/tests/variance/OutPosition.kt | 2 +- .../tests/variance/OutPosition.txt | 2 +- ...iVariableDeclarationWithDisabledFeature.kt | 19 + ...VariableDeclarationWithDisabledFeature.txt | 17 + ...tiVariableDeclarationWithEnabledFeature.kt | 20 + ...iVariableDeclarationWithEnabledFeature.txt | 17 + .../trailingComma/noDisambiguation.kt | 10 + .../trailingComma/noDisambiguation.txt | 5 + .../typeArgumentsWithDisabledFeature.kt | 28 + .../typeArgumentsWithDisabledFeature.txt | 25 + .../typeArgumentsWithEnabledFeature.kt | 28 + .../typeArgumentsWithEnabledFeature.txt | 25 + .../typeParametersWithDisabledFeature.kt | 48 + .../typeParametersWithDisabledFeature.txt | 51 + .../typeParametersWithEnabledFeature.kt | 51 + .../typeParametersWithEnabledFeature.txt | 52 + .../valueArgumentsWithDisabledFeature.kt | 73 + .../valueArgumentsWithDisabledFeature.txt | 47 + .../valueArgumentsWithEnabledFeature.kt | 69 + .../valueArgumentsWithEnabledFeature.txt | 47 + .../valueParametersWithDisabledFeature.kt | 120 ++ .../valueParametersWithDisabledFeature.txt | 68 + .../valueParametersWithEnabledFeature.kt | 104 ++ .../valueParametersWithEnabledFeature.txt | 65 + .../whenEntryWithDisabledFeature.kt | 49 + .../whenEntryWithDisabledFeature.txt | 9 + .../whenEntryWithEnabledFeature.kt | 50 + .../whenEntryWithEnabledFeature.txt | 9 + .../testData/psi/CollectionLiterals_ERR.txt | 2 - compiler/testData/psi/ForWithMultiDecl.txt | 6 +- .../testData/psi/FunctionLiterals_ERR.txt | 14 +- compiler/testData/psi/FunctionTypes.kt | 2 + compiler/testData/psi/FunctionTypes.txt | 29 +- compiler/testData/psi/FunctionTypes_ERR.kt | 1 - compiler/testData/psi/FunctionTypes_ERR.txt | 33 - .../psi/MultiVariableDeclarations.txt | 6 +- compiler/testData/psi/TypeAlias_ERR.txt | 2 - .../psi/platformTypesRecovery/MapEntry.txt | 4 +- compiler/testData/psi/trailingCommaAllowed.kt | 157 ++ .../testData/psi/trailingCommaAllowed.txt | 1537 +++++++++++++++++ .../testData/psi/trailingCommaForbidden.kt | 109 ++ .../testData/psi/trailingCommaForbidden.txt | 1289 ++++++++++++++ .../DiagnosticsTestWithStdLibGenerated.java | 78 + ...ticsTestWithStdLibUsingJavacGenerated.java | 78 + .../codegen/BlackBoxCodegenTestGenerated.java | 18 + .../LightAnalysisModeTestGenerated.java | 18 + .../ir/IrBlackBoxCodegenTestGenerated.java | 18 + .../kotlin/parsing/ParsingTestGenerated.java | 15 +- .../kotlin/config/LanguageVersionSettings.kt | 1 + .../NotFirstParameter.after.kt | 2 +- ...ignMultilineParametersInCalls.after.inv.kt | 2 +- ...ngAlignMultilineParametersInCalls.after.kt | 2 +- .../mismatchingArgs/notForIncompleteCall.test | 1 + .../primaryParameter/valOnUserType.kt | 1 + .../primaryParameter/valOnUserType.kt.after | 1 + .../primaryParameter/varOnUserType.kt | 1 + .../primaryParameter/varOnUserType.kt.after | 1 + .../kotlin/idea/editor/TypedHandlerTest.kt | 4 +- .../IrJsCodegenBoxTestGenerated.java | 18 + .../semantics/JsCodegenBoxTestGenerated.java | 18 + 83 files changed, 4717 insertions(+), 96 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/TrailingCommaChecker.kt create mode 100644 compiler/testData/codegen/box/trailingComma/noDisambiguation.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.txt delete mode 100644 compiler/testData/psi/FunctionTypes_ERR.kt delete mode 100644 compiler/testData/psi/FunctionTypes_ERR.txt create mode 100644 compiler/testData/psi/trailingCommaAllowed.kt create mode 100644 compiler/testData/psi/trailingCommaAllowed.txt create mode 100644 compiler/testData/psi/trailingCommaForbidden.kt create mode 100644 compiler/testData/psi/trailingCommaForbidden.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt index 3c90fb0ece8..57157ebc914 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt @@ -32,11 +32,12 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( ReservedMembersAndConstructsForInlineClass(), ResultClassInReturnTypeChecker(), LocalVariableTypeParametersChecker(), - TailrecFunctionChecker + TailrecFunctionChecker, + TrailingCommaDeclarationChecker ) private val DEFAULT_CALL_CHECKERS = listOf( - CapturingInClosureChecker(), InlineCheckerWrapper(), SafeCallChecker(), + CapturingInClosureChecker(), InlineCheckerWrapper(), SafeCallChecker(), TrailingCommaCallChecker, DeprecatedCallChecker, CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(), ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker, CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker, MissingDependencyClassChecker, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index ba3f5949f5c..cbb9a24c412 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.PossiblyBareType.type import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope import org.jetbrains.kotlin.resolve.calls.checkers.checkCoroutinesFeature import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallableDescriptors +import org.jetbrains.kotlin.resolve.checkers.TrailingCommaChecker import org.jetbrains.kotlin.resolve.descriptorUtil.findImplicitOuterClassArguments import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter import org.jetbrains.kotlin.resolve.scopes.LexicalScope @@ -289,6 +290,8 @@ class TypeResolver( val returnType = if (returnTypeRef != null) resolveType(c.noBareTypes(), returnTypeRef) else moduleDescriptor.builtIns.unitType + TrailingCommaChecker.check(type.parameterList?.trailingComma, c.trace, languageVersionSettings) + result = type( createFunctionType( moduleDescriptor.builtIns, annotations, receiverType, @@ -449,6 +452,10 @@ class TypeResolver( ): PossiblyBareType { val qualifierParts = qualifierResolutionResult.qualifierParts + if (element is KtUserType) { + TrailingCommaChecker.check(element.typeArgumentList?.trailingComma, c.trace, languageVersionSettings) + } + return when (descriptor) { is TypeParameterDescriptor -> { assert(qualifierParts.size == 1) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/TrailingCommaChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/TrailingCommaChecker.kt new file mode 100644 index 00000000000..8d1103e48af --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/TrailingCommaChecker.kt @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker +import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker +import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.types.KotlinType + +// TODO: remove these checkers before 1.4 is released + +object TrailingCommaChecker { + fun check(trailingComma: PsiElement?, trace: BindingTrace, languageVersionSettings: LanguageVersionSettings) { + if (!languageVersionSettings.supportsFeature(LanguageFeature.TrailingCommas) && trailingComma != null) { + trace.report(Errors.UNSUPPORTED_FEATURE.on(trailingComma, LanguageFeature.TrailingCommas to languageVersionSettings)) + } + } +} + +object TrailingCommaDeclarationChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + when (declaration) { + is KtClass -> { + TrailingCommaChecker.check(declaration.typeParameterList?.trailingComma, context.trace, context.languageVersionSettings) + } + is KtCallableDeclaration -> { // also it's executed for anonymous function declarations + TrailingCommaChecker.check(declaration.valueParameterList?.trailingComma, context.trace, context.languageVersionSettings) + TrailingCommaChecker.check(declaration.typeParameterList?.trailingComma, context.trace, context.languageVersionSettings) + if (declaration is KtProperty && declaration.setter != null) { + TrailingCommaChecker.check( + declaration.setter?.parameterList?.trailingComma, + context.trace, + context.languageVersionSettings + ) + } + } + is KtDestructuringDeclaration -> { + TrailingCommaChecker.check(declaration.trailingComma, context.trace, context.languageVersionSettings) + } + is KtTypeAlias -> { + TrailingCommaChecker.check(declaration.typeParameterList?.trailingComma, context.trace, context.languageVersionSettings) + } + } + } +} + +object TrailingCommaCallChecker : CallChecker { + override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { + when (val callElement = resolvedCall.call.callElement) { + is KtArrayAccessExpression -> TrailingCommaChecker.check( + callElement.trailingComma, + context.trace, + context.languageVersionSettings + ) + is KtCollectionLiteralExpression -> TrailingCommaChecker.check( + callElement.trailingComma, + context.trace, + context.languageVersionSettings + ) + is KtWhenExpression -> { + if (callElement.subjectExpression != null) { + callElement.entries.forEach { whenEntry -> + TrailingCommaChecker.check(whenEntry.trailingComma, context.trace, context.languageVersionSettings) + } + } + } + else -> { + resolvedCall.call.run { + TrailingCommaChecker.check(valueArgumentList?.trailingComma, context.trace, context.languageVersionSettings) + } + } + } + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java index f2b933da830..646d2062eef 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue; import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionCallbacksImpl; import org.jetbrains.kotlin.resolve.calls.tower.LambdaContextInfo; +import org.jetbrains.kotlin.resolve.checkers.TrailingCommaChecker; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.inline.InlineUtil; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; @@ -490,6 +491,13 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { @Override public KotlinTypeInfo visitTryExpression(@NotNull KtTryExpression expression, ExpressionTypingContext typingContext) { + expression.getCatchClauses().forEach((catchClause) -> { + KtParameterList parameters = catchClause.getParameterList(); + if (parameters != null) { + TrailingCommaChecker.INSTANCE.check(parameters.getTrailingComma(), typingContext.trace, typingContext.languageVersionSettings); + } + }); + if (typingContext.languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) { return resolveTryExpressionWithNewInference(expression, typingContext); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DestructuringDeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DestructuringDeclarationResolver.kt index 1e45ab399f6..0ee0f966aa7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DestructuringDeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DestructuringDeclarationResolver.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.DataClassDescriptorResolver import org.jetbrains.kotlin.resolve.LocalVariableResolver import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.calls.context.ContextDependency +import org.jetbrains.kotlin.resolve.checkers.TrailingCommaChecker import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue @@ -56,6 +57,8 @@ class DestructuringDeclarationResolver( result.add(variableDescriptor) } + TrailingCommaChecker.check(destructuringDeclaration.trailingComma, context.trace, context.languageVersionSettings) + return result } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index 67d3c4ad8ed..58463f0bdf7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -25,6 +25,8 @@ import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.BindingContext.EXPECTED_RETURN_TYPE import org.jetbrains.kotlin.resolve.calls.context.ContextDependency import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor +import org.jetbrains.kotlin.resolve.checkers.TrailingCommaChecker +import org.jetbrains.kotlin.resolve.checkers.TrailingCommaDeclarationChecker import org.jetbrains.kotlin.resolve.checkers.UnderscoreChecker import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope @@ -141,6 +143,11 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre components.identifierChecker.checkDeclaration(it, context.trace) UnderscoreChecker.checkNamed(it, context.trace, components.languageVersionSettings, allowSingleUnderscore = true) } + TrailingCommaChecker.check( + expression.functionLiteral.valueParameterList?.trailingComma, + context.trace, + context.languageVersionSettings + ) val safeReturnType = computeReturnType(expression, context, functionDescriptor, functionTypeExpected) functionDescriptor.setReturnType(safeReturnType) diff --git a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java index b828c8eb563..b7ba9fa381e 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java +++ b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java @@ -933,6 +933,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { parseWhenCondition(); if (!at(COMMA)) break; advance(); // COMMA + if (at(ARROW)) { + break; + } } expect(ARROW, "Expecting '->'", WHEN_CONDITION_RECOVERY_SET); @@ -1032,22 +1035,13 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { } private void parseInnerExpressions(String missingElementErrorMessage) { - boolean firstElement = true; while (true) { if (at(COMMA)) errorAndAdvance(missingElementErrorMessage); if (at(RBRACKET)) { - if (firstElement) { - break; - } - else { - error(missingElementErrorMessage); - } break; } parseExpression(); - firstElement = false; - if (!at(COMMA)) break; advance(); // COMMA } @@ -1202,6 +1196,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { PsiBuilder.Marker parameterList = mark(); while (!eof()) { + if (at(ARROW)) { + break; + } PsiBuilder.Marker parameter = mark(); if (at(COLON)) { @@ -1521,6 +1518,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { expect(LPAR, "Expecting '('", recoverySet); if (!atSet(recoverySet)) { myKotlinParsing.parseValueParameter(/*typeRequired = */ true); + if (at(COMMA)) { + advance(); // trailing comma + } expect(RPAR, "Expecting ')'", recoverySet); } else { @@ -1813,7 +1813,6 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { } advance(); // COMMA if (at(RPAR)) { - error("Expecting an argument"); break; } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index cf0024f55fd..6c45c835914 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -1466,7 +1466,7 @@ public class KotlinParsing extends AbstractKotlinParsing { if (at(COMMA)) { errorAndAdvance("Expecting a name"); } - else if (at(RPAR)) { + else if (at(RPAR)) { // For declaration similar to `val () = somethingCall()` error("Expecting a name"); break; } @@ -1484,6 +1484,7 @@ public class KotlinParsing extends AbstractKotlinParsing { if (!at(COMMA)) break; advance(); // COMMA + if (at(RPAR)) break; } } @@ -1549,10 +1550,13 @@ public class KotlinParsing extends AbstractKotlinParsing { expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(RPAR, COLON, LBRACE, EQ)); if (at(COLON)) { - advance(); // COLON + advance(); // COLON parseTypeRef(); } setterParameter.done(VALUE_PARAMETER); + if (at(COMMA)) { + advance(); // COMMA + } parameterList.done(VALUE_PARAMETER_LIST); } if (!at(RPAR)) { @@ -1896,6 +1900,9 @@ public class KotlinParsing extends AbstractKotlinParsing { if (!at(COMMA)) break; advance(); // COMMA + if (at(GT)) { + break; + } } expect(GT, "Missing '>'", recoverySet); @@ -2263,6 +2270,9 @@ public class KotlinParsing extends AbstractKotlinParsing { projection.done(TYPE_PROJECTION); if (!at(COMMA)) break; advance(); // COMMA + if (at(GT)) { + break; + } } boolean atGT = at(GT); @@ -2325,7 +2335,6 @@ public class KotlinParsing extends AbstractKotlinParsing { errorAndAdvance("Expecting a parameter declaration"); } else if (at(RPAR)) { - error("Expecting a parameter declaration"); break; } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtArrayAccessExpression.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtArrayAccessExpression.java index b565b9bcdbc..f050a07be68 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtArrayAccessExpression.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtArrayAccessExpression.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.KtNodeTypes; import org.jetbrains.kotlin.lexer.KtTokens; +import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import java.util.Collections; import java.util.List; @@ -75,4 +76,8 @@ public class KtArrayAccessExpression extends KtExpressionImpl implements KtRefer public PsiElement getRightBracket() { return getIndicesNode().findChildByType(KtTokens.RBRACKET); } + + public PsiElement getTrailingComma() { + return KtPsiUtilKt.getTrailingCommaByClosingElement(getRightBracket()); + } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt index 3a566345653..20588be5bc8 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt @@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.psiUtil.getTrailingCommaByClosingElement class KtCollectionLiteralExpression(node: ASTNode) : KtExpressionImpl(node), KtReferenceExpression { override fun accept(visitor: KtVisitor, data: D): R { @@ -32,6 +33,9 @@ class KtCollectionLiteralExpression(node: ASTNode) : KtExpressionImpl(node), KtR val rightBracket: PsiElement? get() = findChildByType(KtTokens.RBRACKET) + val trailingComma: PsiElement? + get() = getTrailingCommaByClosingElement(rightBracket) + fun getInnerExpressions(): List { return PsiTreeUtil.getChildrenOfTypeAsList(this, KtExpression::class.java) } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtDestructuringDeclaration.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtDestructuringDeclaration.java index 9ce7eac7f96..b44a0277ebb 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtDestructuringDeclaration.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtDestructuringDeclaration.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.KtNodeTypes; import org.jetbrains.kotlin.lexer.KtTokens; +import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import java.util.List; @@ -78,4 +79,9 @@ public class KtDestructuringDeclaration extends KtDeclarationImpl implements KtV public PsiElement getLPar() { return findChildByType(KtTokens.LPAR); } + + @Nullable + public PsiElement getTrailingComma() { + return KtPsiUtilKt.getTrailingCommaByClosingElement(getRPar()); + } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameterList.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameterList.java index 6a241ba296c..0db80555c85 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameterList.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtParameterList.java @@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.lexer.KtTokens; +import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub; import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes; @@ -94,4 +95,14 @@ public class KtParameterList extends KtElementImplStub R accept(@NotNull KtVisitor visitor, D data) { return visitor.visitTypeParameterList(this, data); } + + @Nullable + public PsiElement getTrailingComma() { + return KtPsiUtilKt.getTrailingCommaByClosingElement(findChildByType(KtTokens.GT)); + } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtValueArgumentList.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtValueArgumentList.java index 99b244e3592..1979475dec3 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtValueArgumentList.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtValueArgumentList.java @@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.lexer.KtTokens; +import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt; import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub; import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes; @@ -78,4 +79,8 @@ public class KtValueArgumentList extends KtElementImplStub foo(a : T, b : Collection, c : Int) { fun arrayListOf(vararg values: T): ArrayList = throw Exception("$values") -val bar = foo("", arrayListOf(), ) -val bar2 = foo("", arrayListOf(), ) \ No newline at end of file +val bar = foo("", arrayListOf(), ) +val bar2 = foo("", arrayListOf(), ) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/variance/InPosition.kt b/compiler/testData/diagnostics/tests/variance/InPosition.kt index a18da9643fd..d43e21c1949 100644 --- a/compiler/testData/diagnostics/tests/variance/InPosition.kt +++ b/compiler/testData/diagnostics/tests/variance/InPosition.kt @@ -39,7 +39,7 @@ interface Test { fun neOk11(i: Inv")!>I>) fun neOk12(i: Inv")!>O>) - fun neOk30(i: Pair<")!>O, >) + fun neOk30(i: Pair, >) fun neOk31(i: Pair<")!>O, Inv>) fun neOk32(i: Inv) fun neOk33(i: Inv<>) diff --git a/compiler/testData/diagnostics/tests/variance/InPosition.txt b/compiler/testData/diagnostics/tests/variance/InPosition.txt index 4f5436d2207..17c918de3a3 100644 --- a/compiler/testData/diagnostics/tests/variance/InPosition.txt +++ b/compiler/testData/diagnostics/tests/variance/InPosition.txt @@ -43,7 +43,7 @@ public interface Test { public abstract fun neOk12(/*0*/ i: Inv): kotlin.Unit public abstract fun neOk2(/*0*/ i: In): kotlin.Unit public abstract fun neOk3(/*0*/ i: In>): kotlin.Unit - public abstract fun neOk30(/*0*/ i: Pair): kotlin.Unit + public abstract fun neOk30(/*0*/ i: [ERROR : Pair]): kotlin.Unit public abstract fun neOk31(/*0*/ i: Pair): kotlin.Unit public abstract fun neOk32(/*0*/ i: [ERROR : Inv]): kotlin.Unit public abstract fun neOk33(/*0*/ i: Inv<[ERROR : No type element]>): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/variance/InvariantPosition.kt b/compiler/testData/diagnostics/tests/variance/InvariantPosition.kt index 3aa20a8300b..94e6e1ba005 100644 --- a/compiler/testData/diagnostics/tests/variance/InvariantPosition.kt +++ b/compiler/testData/diagnostics/tests/variance/InvariantPosition.kt @@ -36,7 +36,7 @@ interface Test { var neOk22: Inv")!>O> var neOk23: Inv")!>I> - var neOk30: Pair<")!>I, > + var neOk30: Pair, > var neOk31: Pair<")!>I, Inv> var neOk32: Inv var neOk33: Inv<> diff --git a/compiler/testData/diagnostics/tests/variance/InvariantPosition.txt b/compiler/testData/diagnostics/tests/variance/InvariantPosition.txt index 5f79545fb48..5f98f85de1d 100644 --- a/compiler/testData/diagnostics/tests/variance/InvariantPosition.txt +++ b/compiler/testData/diagnostics/tests/variance/InvariantPosition.txt @@ -40,7 +40,7 @@ public interface Test { public abstract var neOk22: Inv public abstract var neOk23: Inv public abstract var neOk3: In> - public abstract var neOk30: Pair + public abstract var neOk30: [ERROR : Pair] public abstract var neOk31: Pair public abstract var neOk32: [ERROR : Inv] public abstract var neOk33: Inv<[ERROR : No type element]> diff --git a/compiler/testData/diagnostics/tests/variance/OutPosition.kt b/compiler/testData/diagnostics/tests/variance/OutPosition.kt index 1a5d5616e3e..e4848e9e3ed 100644 --- a/compiler/testData/diagnostics/tests/variance/OutPosition.kt +++ b/compiler/testData/diagnostics/tests/variance/OutPosition.kt @@ -31,7 +31,7 @@ interface Test { fun neOk10(): Inv")!>O> fun neOk11(): Inv")!>I> - fun neOk30(): Pair<")!>I, > + fun neOk30(): Pair, > fun neOk31(): Pair<")!>I, Inv> fun neOk32(): Inv fun neOk33(): Inv<> diff --git a/compiler/testData/diagnostics/tests/variance/OutPosition.txt b/compiler/testData/diagnostics/tests/variance/OutPosition.txt index 198ee566b72..fe9aacbe2e3 100644 --- a/compiler/testData/diagnostics/tests/variance/OutPosition.txt +++ b/compiler/testData/diagnostics/tests/variance/OutPosition.txt @@ -32,7 +32,7 @@ public interface Test { public abstract fun neOk11(): Inv public abstract fun neOk2(): In public abstract fun neOk3(): In> - public abstract fun neOk30(): Pair + public abstract fun neOk30(): [ERROR : Pair] public abstract fun neOk31(): Pair public abstract fun neOk32(): [ERROR : Inv] public abstract fun neOk33(): Inv<[ERROR : No type element]> diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt new file mode 100644 index 00000000000..37c1ef2db78 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt @@ -0,0 +1,19 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_DESTRUCTURED_PARAMETER_ENTRY, -UNUSED_ANONYMOUS_PARAMETER + +data class Foo1(val x: String, val y: String, val z: String = "") + +fun main() { + val (x1,y1,) = Pair(1,2) + val (x2, y2: Number,) = Pair(1,2) + val (x3,y3,z3,) = Foo1("", "", ) + val (x4,y4: CharSequence,) = Foo1("", "", "",) + val (x41,y41: CharSequence,/**/) = Foo1("", "", "",) + + val x5: (Pair, Int) -> Unit = { (x,y,),z, -> } + val x6: (Foo1, Int) -> Any = { (x,y,z: CharSequence,), z1: Number, -> 1 } + val x61: (Foo1, Int) -> Any = { (x,y,z: CharSequence,/**/), z1: Number,/**/ -> 1 } + + for ((i, j,) in listOf(Pair(1,2))) {} + for ((i: Any,) in listOf(Pair(1,2))) {} + for ((i: Any,/**/) in listOf(Pair(1,2))) {} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.txt new file mode 100644 index 00000000000..36b440d5fc2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.txt @@ -0,0 +1,17 @@ +package + +public fun main(): kotlin.Unit + +public final data class Foo1 { + public constructor Foo1(/*0*/ x: kotlin.String, /*1*/ y: kotlin.String, /*2*/ z: kotlin.String = ...) + public final val x: kotlin.String + public final val y: kotlin.String + public final val z: kotlin.String + public final operator /*synthesized*/ fun component1(): kotlin.String + public final operator /*synthesized*/ fun component2(): kotlin.String + public final operator /*synthesized*/ fun component3(): kotlin.String + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): Foo1 + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt new file mode 100644 index 00000000000..4bf34c3afc0 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_DESTRUCTURED_PARAMETER_ENTRY, -UNUSED_ANONYMOUS_PARAMETER +// !LANGUAGE: +TrailingCommas + +data class Foo1(val x: String, val y: String, val z: String = "") + +fun main() { + val (x1,y1,) = Pair(1, 2) + val (x2, y2: Number,) = Pair(1,2) + val (x3,y3,z3,) = Foo1("", "",) + val (x4,y4: CharSequence,) = Foo1("", "", "",) + val (x41,y41: CharSequence,/**/) = Foo1("", "", "",) + + val x5: (Pair, Int) -> Unit = { (x,y,),z, -> } + val x6: (Foo1, Int) -> Any = { (x,y,z: CharSequence,), z2: Number, -> 1 } + val x61: (Foo1, Int) -> Any = { (x,y,z: CharSequence,/**/), z2: Number,/**/ -> 1 } + + for ((i, j) in listOf(Pair(1,2))) {} + for ((i: Any,) in listOf(Pair(1,2))) {} + for ((i: Any,/**/) in listOf(Pair(1,2))) {} +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.txt new file mode 100644 index 00000000000..36b440d5fc2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.txt @@ -0,0 +1,17 @@ +package + +public fun main(): kotlin.Unit + +public final data class Foo1 { + public constructor Foo1(/*0*/ x: kotlin.String, /*1*/ y: kotlin.String, /*2*/ z: kotlin.String = ...) + public final val x: kotlin.String + public final val y: kotlin.String + public final val z: kotlin.String + public final operator /*synthesized*/ fun component1(): kotlin.String + public final operator /*synthesized*/ fun component2(): kotlin.String + public final operator /*synthesized*/ fun component3(): kotlin.String + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): Foo1 + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt new file mode 100644 index 00000000000..78df6b74bc2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER +// !LANGUAGE: +TrailingCommas + +fun foo(vararg x: Int) = false +fun foo() = true + +fun main() { + val x = foo() + val y = foo(,) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.txt new file mode 100644 index 00000000000..40d3730c7f0 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.txt @@ -0,0 +1,5 @@ +package + +public fun foo(): kotlin.Boolean +public fun foo(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Boolean +public fun main(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt new file mode 100644 index 00000000000..f6b4020ad2c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt @@ -0,0 +1,28 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_TYPEALIAS_PARAMETER, -CAST_NEVER_SUCCEEDS + +class Foo1 {} + +interface Foo2,> + +fun foo3() {} + +typealias Foo4 = Int + +class Foo5,>: Foo2,> + +fun foo() { + val x1 = Foo1() + val x2: Foo2,>? = null + val x21: Foo2,/**/>? = null + val x3 = foo3< + Int, + String, + Float, + >() + val x4: Foo4,>, Iterable,>,>, Double, T, + >? = null as Foo4,>, Iterable,>,>, Double, T,> + val x5: (Float,) -> Unit = {} + val x6: Pair<(Float, Comparable,>,) -> Unit, (Float,) -> Unit,>? = null + val x61: Pair<(Float, Comparable,/**/>,/**/) -> Unit, (Float,/**/) -> Unit,/**/>? = null +} + diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.txt new file mode 100644 index 00000000000..72e9baf1d4c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.txt @@ -0,0 +1,25 @@ +package + +public fun foo(): kotlin.Unit +public fun foo3(): kotlin.Unit + +public final class Foo1 { + public constructor Foo1() + 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 +} + +public interface Foo2 { + 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 +} + +public final class Foo5 : Foo2 { + public constructor Foo5() + 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 +} +public typealias Foo4 = kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt new file mode 100644 index 00000000000..3485444781e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt @@ -0,0 +1,28 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_TYPEALIAS_PARAMETER, -CAST_NEVER_SUCCEEDS +// !LANGUAGE: +TrailingCommas + +class Foo1 {} + +interface Foo2 + +fun foo3() {} + +typealias Foo4 = Int + +class Foo5: Foo2 + +fun foo () { + val x1 = Foo1() + val x2: Foo2? = null + val x21: Foo2? = null + val x3 = foo3< + Int, + String, + Float, + >() + val x4: Foo4, Iterable,>, Double, T, + >? = null as Foo4, Iterable,>, Double, T,> + val x5: (Float,) -> Unit = {} + val x6: Pair<(Float, Comparable,) -> Unit, (Float,) -> Unit,>? = null + val x61: Pair<(Float, Comparable,/**/) -> Unit, (Float,/**/) -> Unit,/**/>? = null +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.txt new file mode 100644 index 00000000000..72e9baf1d4c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.txt @@ -0,0 +1,25 @@ +package + +public fun foo(): kotlin.Unit +public fun foo3(): kotlin.Unit + +public final class Foo1 { + public constructor Foo1() + 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 +} + +public interface Foo2 { + 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 +} + +public final class Foo5 : Foo2 { + public constructor Foo5() + 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 +} +public typealias Foo4 = kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt new file mode 100644 index 00000000000..f37a8147271 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt @@ -0,0 +1,48 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_TYPEALIAS_PARAMETER + +@Target(AnnotationTarget.TYPE) +annotation class Anno + +class Foo1,> + +class Foo2< + T1, + T2: T1, + > { + fun , > foo2() {} + + internal inner class B,> +} + +interface A,> + +interface A1,/**/> + +fun ,> foo1() {} + +fun ,/**/> foo11() {} + +fun , + > T2?.foo2() {} + +val ,> T.bar1 get() = null + +var < + T4, + > T4?.bar2 + get() = null + set(value) { + + } + +typealias Foo3,> = List + +typealias Foo4,/**/> = List + +fun main() { + fun ,> foo10() { + fun ,> foo10() {} + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt new file mode 100644 index 00000000000..7814fadbf1e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt @@ -0,0 +1,51 @@ +package + +public val T.bar1: kotlin.Nothing? +public var T4?.bar2: kotlin.Nothing? +public fun foo1(): kotlin.Unit +public fun foo11(): kotlin.Unit +public fun main(): kotlin.Unit +public fun T2?.foo2(): kotlin.Unit + +public interface A { + 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 +} + +public interface A1 { + 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation { + public constructor Anno() + 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 +} + +public final class Foo1 { + public constructor Foo1() + 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 +} + +public final class Foo2 { + public constructor Foo2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal final inner class B /*captured type parameters: /*2*/ T1, /*3*/ T2 : T1*/ { + public constructor B() + 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 + } +} +public typealias Foo3 = kotlin.collections.List +public typealias Foo4 = kotlin.collections.List diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt new file mode 100644 index 00000000000..bb48ef27620 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt @@ -0,0 +1,51 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_TYPEALIAS_PARAMETER +// !LANGUAGE: +TrailingCommas + +@Target(AnnotationTarget.TYPE) +annotation class Anno + +class Foo1 + +class Foo2< + T1, + T2: T1, + > { + fun foo2() {} + + internal inner class B +} + +interface A + +interface A1 + +fun foo1() {} + +fun foo11() {} + +inline fun foo2() {} + +fun T2?.foo3() {} + +val T.bar1 get() = null + +var < + T4, + > T4?.bar2 + get() = null + set(value) { + + } + +typealias Foo3 = List + +typealias Foo4 = List + +fun main() { + fun foo10() { + fun foo10() {} + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt new file mode 100644 index 00000000000..d531e7f7b5c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt @@ -0,0 +1,52 @@ +package + +public val T.bar1: kotlin.Nothing? +public var T4?.bar2: kotlin.Nothing? +public fun foo1(): kotlin.Unit +public fun foo11(): kotlin.Unit +public inline fun foo2(): kotlin.Unit +public fun main(): kotlin.Unit +public fun T2?.foo3(): kotlin.Unit + +public interface A { + 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 +} + +public interface A1 { + 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation { + public constructor Anno() + 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 +} + +public final class Foo1 { + public constructor Foo1() + 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 +} + +public final class Foo2 { + public constructor Foo2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal final inner class B /*captured type parameters: /*2*/ T1, /*3*/ T2 : T1*/ { + public constructor B() + 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 + } +} +public typealias Foo3 = kotlin.collections.List +public typealias Foo4 = kotlin.collections.List diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt new file mode 100644 index 00000000000..fee2116615f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt @@ -0,0 +1,73 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE, -UNUSED_ANONYMOUS_PARAMETER + +@Target(AnnotationTarget.TYPE) +annotation class Anno1(val x: IntArray) + +@Target(AnnotationTarget.TYPEALIAS) +annotation class Anno2(val x: DoubleArray) + +fun foo1(vararg x: Any) {} +fun foo2(x: (Any, Any) -> Unit) {} +fun foo3(x: Any, y: () -> Unit) {} + +open class A1(vararg x: Any) { + operator fun get(x: Any, y: Any) = 10 +} + +open class A2(x: Int, y: () -> Unit) {} + +class B(): A1({},) { + +} + +@Anno2( + [ + 0.4, + .1, + ] +) +typealias A3 = B + +fun main1() { + foo1(1, 2, 3,) + foo1({},) + foo3(10,) {} + foo3(10,/**/) {} + + val x1 = A1(1, 2, 3,) + val y1 = A1({},) + val z1 = A2(10,) {} + + foo2({ x, y -> kotlin.Unit },) + foo2({ x, y -> kotlin.Unit },/**/) + + val foo = listOf( + println(1), + "foo bar something", + ) + + val x2 = x1[ + 1, + 2, + ] + + val x3 = x1[{},{},] + val x31 = x1[{},{},/**/] + + val x4: @Anno1([ + 1, 2, + ]) Float = 0f + + foo1(object {},) + foo1(object {},/**/) + foo1(fun () {},) + foo1(if (true) 1 else 2,) + + foo1(return,) +} + +fun main2(x: A1) { + val x1 = x[object {}, return, ] + val x2 = x[fun () {}, throw Exception(), ] + val x3 = x[fun () {}, throw Exception(),/**/ ] +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.txt new file mode 100644 index 00000000000..79a21f6ef0a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.txt @@ -0,0 +1,47 @@ +package + +public fun foo1(/*0*/ vararg x: kotlin.Any /*kotlin.Array*/): kotlin.Unit +public fun foo2(/*0*/ x: (kotlin.Any, kotlin.Any) -> kotlin.Unit): kotlin.Unit +public fun foo3(/*0*/ x: kotlin.Any, /*1*/ y: () -> kotlin.Unit): kotlin.Unit +public fun main1(): kotlin.Unit +public fun main2(/*0*/ x: A1): kotlin.Unit + +public open class A1 { + public constructor A1(/*0*/ vararg x: kotlin.Any /*kotlin.Array*/) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final operator fun get(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Any): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class A2 { + public constructor A2(/*0*/ x: kotlin.Int, /*1*/ y: () -> 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno1 : kotlin.Annotation { + public constructor Anno1(/*0*/ x: kotlin.IntArray) + public final val x: kotlin.IntArray + 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPEALIAS}) public final annotation class Anno2 : kotlin.Annotation { + public constructor Anno2(/*0*/ x: kotlin.DoubleArray) + public final val x: kotlin.DoubleArray + 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 +} + +public final class B : A1 { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun get(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Any): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +@Anno2(x = {0.4.toDouble(), 0.1.toDouble()}) public typealias A3 = B diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt new file mode 100644 index 00000000000..2aedda03fc1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt @@ -0,0 +1,69 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE, -UNUSED_ANONYMOUS_PARAMETER +// !LANGUAGE: +TrailingCommas + +@Target(AnnotationTarget.TYPE) +annotation class Anno1(val x: IntArray) + +@Target(AnnotationTarget.TYPEALIAS) +annotation class Anno2(val x: DoubleArray) + +fun foo1(vararg x: Any) {} +fun foo2(x: (Any, Any) -> Unit) {} +fun foo3(x: Any, y: () -> Unit) {} + +open class A1(vararg x: Any) { + operator fun get(x: Any, y: Any) = 10 +} + +open class A2(x: Any, y: () -> Unit) + +class B(): A1({},) { + +} + +@Anno2( + [ + 0.4, + .1, + ] +) +typealias A3 = B + +fun main1() { + foo1(1, 2, 3,/**/) + foo1({},) + foo3(10,/**/) {} + + val x1 = A1(1, 2, 3,) + val y1 = A1({},) + val z1 = A2(10,) {} + + foo2({ x, y -> kotlin.Unit },/**/) + + val foo = listOf( + println(1), + "foo bar something", + ) + + val x2 = x1[ + 1, + 2, + ] + + val x3 = x1[{},{},/**/] + + val x4: @Anno1([ + 1, 2,/**/ + ]) Float = 0f + + foo1(object {},) + foo1(fun () {},) + foo1(if (true) 1 else 2,/**/) + + foo1(return,) +} + +fun main2(x: A1) { + val x1 = x[object {}, return, ] + val x2 = x[fun () {}, throw Exception(), /**/] +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.txt new file mode 100644 index 00000000000..626930c4152 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.txt @@ -0,0 +1,47 @@ +package + +public fun foo1(/*0*/ vararg x: kotlin.Any /*kotlin.Array*/): kotlin.Unit +public fun foo2(/*0*/ x: (kotlin.Any, kotlin.Any) -> kotlin.Unit): kotlin.Unit +public fun foo3(/*0*/ x: kotlin.Any, /*1*/ y: () -> kotlin.Unit): kotlin.Unit +public fun main1(): kotlin.Unit +public fun main2(/*0*/ x: A1): kotlin.Unit + +public open class A1 { + public constructor A1(/*0*/ vararg x: kotlin.Any /*kotlin.Array*/) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final operator fun get(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Any): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class A2 { + public constructor A2(/*0*/ x: kotlin.Any, /*1*/ y: () -> 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno1 : kotlin.Annotation { + public constructor Anno1(/*0*/ x: kotlin.IntArray) + public final val x: kotlin.IntArray + 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 +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPEALIAS}) public final annotation class Anno2 : kotlin.Annotation { + public constructor Anno2(/*0*/ x: kotlin.DoubleArray) + public final val x: kotlin.DoubleArray + 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 +} + +public final class B : A1 { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun get(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Any): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +@Anno2(x = {0.4.toDouble(), 0.1.toDouble()}) public typealias A3 = B diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt new file mode 100644 index 00000000000..2d63ccc239f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt @@ -0,0 +1,120 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE + +open class Foo1(x: Int = 10, y: Float = 0f,) + +class Foo2( + val x: Int = 10, + var y: Float, +): Foo1(x, y,) { + constructor( + x: Float, + y: Int = 10, + ): this(1, 1f,) {} + + var x1: Int + get() = 10 + set(value,) { + + } + + var x2: Int + get() = 10 + set( + x2, + ) {} + + var x3: (Int) -> Unit + get() = {} + set(x2: (Int) -> Unit,) {} + + var x4: (Int) -> Unit + get() = {} + set(x2: (Int) -> Unit,/**/) {} +} + +enum class Foo3(x: Int, ) + +fun foo4(x: Int, y: Comparable,) {} + +fun foo5(x: Int = 10,) {} + +fun foo6(vararg x: Int,) {} + +fun foo7(y: Float, vararg x: Int,) {} + +val foo8: (Int, Int,) -> Int = fun( + x, + y, + ): Int { + return x + y +} + +val foo9: (Int, Int, Int,) -> Int = + fun (x, y: Int, z,): Int { + return x + y + } + +open class Foo10(x: Int = 10, y: Float = 0f) + +class Foo11: Foo10 { + constructor( + x: Float + ): super(1, 1f,) +} + +class Foo12: Foo10 { + constructor( + x: Float + ): super(1, 1f,/**/) +} + +fun main() { + val x1 = { + x: Comparable>, + y: Iterable>, + -> + println("1") + } + val x2 = { x: Comparable>, + -> println("1") + } + val x3: ((Int,) -> Int) -> Unit = { x: (Int,) -> Int, -> println("1") } + val x4: ((Int,) -> Int) -> Unit = { x, -> println("1") } + + fun foo10(x:Int,y:Int,) { + fun foo10(x:Int,y:Int,) {} + } + fun foo101(x:Int,y:Int,/**/) { + fun foo10(x:Int,y:Int,/**/) {} + } + + try { + println(1) + } catch (e: Exception,) { + + } + + try { + println(1) + } catch (e: Exception,) { + + } catch (e: Exception,) { + + } + + try { + println(1) + } catch (e: Exception,) { + + } finally { + + } + + try { + println(1) + } catch (e: Exception,/**/) { + + } finally { + + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.txt new file mode 100644 index 00000000000..d9d66e0946f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.txt @@ -0,0 +1,68 @@ +package + +public val foo8: (kotlin.Int, kotlin.Int) -> kotlin.Int +public val foo9: (kotlin.Int, kotlin.Int, kotlin.Int) -> kotlin.Int +public fun foo4(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Comparable): kotlin.Unit +public fun foo5(/*0*/ x: kotlin.Int = ...): kotlin.Unit +public fun foo6(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +public fun foo7(/*0*/ y: kotlin.Float, /*1*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +public fun main(): kotlin.Unit + +public open class Foo1 { + public constructor Foo1(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float = ...) + 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 +} + +public open class Foo10 { + public constructor Foo10(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float = ...) + 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 +} + +public final class Foo11 : Foo10 { + public constructor Foo11(/*0*/ x: kotlin.Float) + 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 +} + +public final class Foo12 : Foo10 { + public constructor Foo12(/*0*/ x: kotlin.Float) + 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 +} + +public final class Foo2 : Foo1 { + public constructor Foo2(/*0*/ x: kotlin.Float, /*1*/ y: kotlin.Int = ...) + public constructor Foo2(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float) + public final val x: kotlin.Int + public final var x1: kotlin.Int + public final var x2: kotlin.Int + public final var x3: (kotlin.Int) -> kotlin.Unit + public final var x4: (kotlin.Int) -> kotlin.Unit + public final var y: kotlin.Float + 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 +} + +public final enum class Foo3 : kotlin.Enum { + private constructor Foo3(/*0*/ x: kotlin.Int) + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Foo3): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Foo3 + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt new file mode 100644 index 00000000000..40dc6bd5a90 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt @@ -0,0 +1,104 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE +// !LANGUAGE: +TrailingCommas + +open class Foo1(x: Int = 10, y: Float = 0f,) + +class Foo2( + val x: Int = 10, + var y: Float, +): Foo1(x, y) { + constructor( + x: Float, + y: Int = 10, + ): this(1, 1f,) { + + } +} + +enum class Foo3(x: Int, ) + +fun foo4(x: Int, y: Comparable,) {} + +fun foo5(x: Int = 10,) {} + +fun foo6(vararg x: Int,) {} + +fun foo61(vararg x: Int,/**/) {} + +fun foo7(y: Float, vararg x: Int,) {} + +val foo8: (Int, Int,) -> Int = fun( + x, + y, + ): Int { + return x + y +} + +val foo9: (Int, Int, Int,) -> Int = + fun (x, y: Int, z,): Int { + return x + y + } + +open class Foo10(x: Int = 10, y: Float = 0f) + +class Foo11: Foo10 { + constructor( + x: Float + ): super(1, 1f,) +} + +class Foo12: Foo10 { + constructor( + x: Float + ): super(1, 1f,/**/) +} + +fun main() { + val x1 = { + x: Comparable>, + y: Iterable>, + -> + println("1") + } + val x11 = { + x: Comparable>, + y: Iterable>,/**/ + -> + println("1") + } + val x2 = { x: Comparable>, + -> println("1") + } + val x3: ((Int,) -> Int) -> Unit = { x: (Int,) -> Int, -> println("1") } + val x4: ((Int,) -> Int) -> Unit = { x, -> println("1") } + + try { + println(1) + } catch (e: Exception,) { + + } + + try { + println(1) + } catch (e: Exception,) { + + } catch (e: Exception,) { + + } + + try { + println(1) + } catch (e: Exception,) { + + } finally { + + } + + try { + println(1) + } catch (e: Exception,/**/) { + + } finally { + + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.txt new file mode 100644 index 00000000000..50cd3ab8233 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.txt @@ -0,0 +1,65 @@ +package + +public val foo8: (kotlin.Int, kotlin.Int) -> kotlin.Int +public val foo9: (kotlin.Int, kotlin.Int, kotlin.Int) -> kotlin.Int +public fun foo4(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Comparable): kotlin.Unit +public fun foo5(/*0*/ x: kotlin.Int = ...): kotlin.Unit +public fun foo6(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +public fun foo61(/*0*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +public fun foo7(/*0*/ y: kotlin.Float, /*1*/ vararg x: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +public fun main(): kotlin.Unit + +public open class Foo1 { + public constructor Foo1(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float = ...) + 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 +} + +public open class Foo10 { + public constructor Foo10(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float = ...) + 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 +} + +public final class Foo11 : Foo10 { + public constructor Foo11(/*0*/ x: kotlin.Float) + 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 +} + +public final class Foo12 : Foo10 { + public constructor Foo12(/*0*/ x: kotlin.Float) + 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 +} + +public final class Foo2 : Foo1 { + public constructor Foo2(/*0*/ x: kotlin.Float, /*1*/ y: kotlin.Int = ...) + public constructor Foo2(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Float) + public final val x: kotlin.Int + public final var y: kotlin.Float + 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 +} + +public final enum class Foo3 : kotlin.Enum { + private constructor Foo3(/*0*/ x: kotlin.Int) + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Foo3): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Foo3 + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt new file mode 100644 index 00000000000..80cee86541b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt @@ -0,0 +1,49 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_EXPRESSION -NAME_SHADOWING + +fun foo1(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class, + -> println(1) + else -> println(3) +} + +fun foo2(x: Any) { + val z = when (val y: Int = x as Int) { + 1, -> println(1) + else -> println(3) + } +} + +fun foo3(x: (Any) -> Any) { + val z = when (val y: (Any) -> Any = x) { + {x: Any, -> x}, {y: Any, -> y}, -> println(1) + else -> println(3) + } +} + +fun foo4(x: Any) { + val z = when (x) { + is Int, is Double, -> println(1) + else -> println(3) + } +} + +fun foo5(x: Int, y: IntArray, z: IntArray) { + val u = when (x) { + in y, + in z, + -> println(1) + else -> println(3) + } +} + +fun foo6(x: Boolean?) = when (x) { + true, false, -> println(1) + null, -> println(1) +} + +fun foo7(x: Boolean?) = when (x) { + true, false,/**/ -> println(1) + null,/**/ -> println(1) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.txt new file mode 100644 index 00000000000..48c319c18b3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.txt @@ -0,0 +1,9 @@ +package + +public fun foo1(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo2(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo3(/*0*/ x: (kotlin.Any) -> kotlin.Any): kotlin.Unit +public fun foo4(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo5(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.IntArray, /*2*/ z: kotlin.IntArray): kotlin.Unit +public fun foo6(/*0*/ x: kotlin.Boolean?): kotlin.Unit +public fun foo7(/*0*/ x: kotlin.Boolean?): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt new file mode 100644 index 00000000000..aabceebf900 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt @@ -0,0 +1,50 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -NAME_SHADOWING +// !LANGUAGE: +TrailingCommas + +fun foo1(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class, + -> println(1) + else -> println(3) +} + +fun foo2(x: Any) { + val z = when (val y: Int = x as Int) { + 1, -> println(1) + else -> println(3) + } +} + +fun foo3(x: (Any) -> Any) { + val z = when (val y: (Any) -> Any = x) { + {x: Any, -> x}, {y: Any, -> y}, -> println(1) + else -> println(3) + } +} + +fun foo4(x: Any) { + val z = when (x) { + is Int, is Double, -> println(1) + else -> println(3) + } +} + +fun foo5(x: Int, y: IntArray, z: IntArray) { + val u = when (x) { + in y, + in z, + -> println(1) + else -> println(3) + } +} + +fun foo6(x: Boolean?) = when (x) { + true, false, -> println(1) + null, -> println(1) +} + +fun foo7(x: Boolean?) = when (x) { + true, false,/**/ -> println(1) + null,/**/ -> println(1) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.txt new file mode 100644 index 00000000000..48c319c18b3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.txt @@ -0,0 +1,9 @@ +package + +public fun foo1(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo2(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo3(/*0*/ x: (kotlin.Any) -> kotlin.Any): kotlin.Unit +public fun foo4(/*0*/ x: kotlin.Any): kotlin.Unit +public fun foo5(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.IntArray, /*2*/ z: kotlin.IntArray): kotlin.Unit +public fun foo6(/*0*/ x: kotlin.Boolean?): kotlin.Unit +public fun foo7(/*0*/ x: kotlin.Boolean?): kotlin.Unit diff --git a/compiler/testData/psi/CollectionLiterals_ERR.txt b/compiler/testData/psi/CollectionLiterals_ERR.txt index 19d289d2aa9..96c2091154e 100644 --- a/compiler/testData/psi/CollectionLiterals_ERR.txt +++ b/compiler/testData/psi/CollectionLiterals_ERR.txt @@ -25,8 +25,6 @@ KtFile: CollectionLiterals_ERR.kt INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiElement(COMMA)(',') - PsiErrorElement:Expecting an element - PsiWhiteSpace(' ') PsiElement(RBRACKET)(']') PsiWhiteSpace('\n ') diff --git a/compiler/testData/psi/ForWithMultiDecl.txt b/compiler/testData/psi/ForWithMultiDecl.txt index 5c5e227d175..05916a2e11b 100644 --- a/compiler/testData/psi/ForWithMultiDecl.txt +++ b/compiler/testData/psi/ForWithMultiDecl.txt @@ -533,8 +533,6 @@ KtFile: ForWithMultiDecl.kt DESTRUCTURING_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') @@ -593,8 +591,6 @@ KtFile: ForWithMultiDecl.kt PsiErrorElement:Type expected PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') @@ -687,4 +683,4 @@ KtFile: ForWithMultiDecl.kt PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/FunctionLiterals_ERR.txt b/compiler/testData/psi/FunctionLiterals_ERR.txt index 82cc1f5af20..07d0ea06924 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.txt +++ b/compiler/testData/psi/FunctionLiterals_ERR.txt @@ -80,8 +80,6 @@ KtFile: FunctionLiterals_ERR.kt DESTRUCTURING_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') @@ -245,10 +243,7 @@ KtFile: FunctionLiterals_ERR.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_PARAMETER - PsiErrorElement:Expecting parameter name - + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK @@ -306,10 +301,7 @@ KtFile: FunctionLiterals_ERR.kt VALUE_PARAMETER PsiElement(IDENTIFIER)('a') PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_PARAMETER - PsiErrorElement:Expecting parameter name - + PsiWhiteSpace(' ') PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK @@ -827,4 +819,4 @@ KtFile: FunctionLiterals_ERR.kt PsiWhiteSpace(' ') PsiElement(RBRACE)('}') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/FunctionTypes.kt b/compiler/testData/psi/FunctionTypes.kt index faa96b53279..9ea1a0ae719 100644 --- a/compiler/testData/psi/FunctionTypes.kt +++ b/compiler/testData/psi/FunctionTypes.kt @@ -20,3 +20,5 @@ typealias f = T.T.() -> Unit typealias f = @[a] T.() -> Unit typealias f = @[a] T.T.() -> Unit typealias f = @[a] T.T.() -> Unit + +typealias f = (a, ) -> b diff --git a/compiler/testData/psi/FunctionTypes.txt b/compiler/testData/psi/FunctionTypes.txt index 48f50d9f82d..1aaf41869be 100644 --- a/compiler/testData/psi/FunctionTypes.txt +++ b/compiler/testData/psi/FunctionTypes.txt @@ -680,4 +680,31 @@ KtFile: FunctionTypes.kt TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Unit') \ No newline at end of file + PsiElement(IDENTIFIER)('Unit') + PsiWhiteSpace('\n\n') + TYPEALIAS + PsiElement(typealias)('typealias') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') \ No newline at end of file diff --git a/compiler/testData/psi/FunctionTypes_ERR.kt b/compiler/testData/psi/FunctionTypes_ERR.kt deleted file mode 100644 index 14ef9e8387b..00000000000 --- a/compiler/testData/psi/FunctionTypes_ERR.kt +++ /dev/null @@ -1 +0,0 @@ -typealias f = (a, ) -> b diff --git a/compiler/testData/psi/FunctionTypes_ERR.txt b/compiler/testData/psi/FunctionTypes_ERR.txt deleted file mode 100644 index 45ca25f9c2f..00000000000 --- a/compiler/testData/psi/FunctionTypes_ERR.txt +++ /dev/null @@ -1,33 +0,0 @@ -KtFile: FunctionTypes_ERR.kt - PACKAGE_DIRECTIVE - - IMPORT_LIST - - TYPEALIAS - PsiElement(typealias)('typealias') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('f') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') - TYPE_REFERENCE - FUNCTION_TYPE - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - VALUE_PARAMETER - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiErrorElement:Expecting a parameter declaration - - PsiWhiteSpace(' ') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') diff --git a/compiler/testData/psi/MultiVariableDeclarations.txt b/compiler/testData/psi/MultiVariableDeclarations.txt index 65ce1de451c..0e6acd77c34 100644 --- a/compiler/testData/psi/MultiVariableDeclarations.txt +++ b/compiler/testData/psi/MultiVariableDeclarations.txt @@ -298,8 +298,6 @@ KtFile: MultiVariableDeclarations.kt DESTRUCTURING_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') @@ -350,8 +348,6 @@ KtFile: MultiVariableDeclarations.kt REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Int') PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') @@ -616,4 +612,4 @@ KtFile: MultiVariableDeclarations.kt INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/TypeAlias_ERR.txt b/compiler/testData/psi/TypeAlias_ERR.txt index de9fd1c608a..8ce9f69ecac 100644 --- a/compiler/testData/psi/TypeAlias_ERR.txt +++ b/compiler/testData/psi/TypeAlias_ERR.txt @@ -139,8 +139,6 @@ KtFile: TypeAlias_ERR.kt TYPE_PARAMETER PsiElement(IDENTIFIER)('T') PsiElement(COMMA)(',') - PsiErrorElement:Type parameter declaration expected - PsiWhiteSpace(' ') PsiElement(GT)('>') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/platformTypesRecovery/MapEntry.txt b/compiler/testData/psi/platformTypesRecovery/MapEntry.txt index 1c1953e5ab4..ecb2334ed05 100644 --- a/compiler/testData/psi/platformTypesRecovery/MapEntry.txt +++ b/compiler/testData/psi/platformTypesRecovery/MapEntry.txt @@ -95,11 +95,9 @@ KtFile: MapEntry.kt PsiErrorElement:Unexpected token PsiElement(EXCL)('!') PsiElement(COMMA)(',') - PsiErrorElement:Expecting a parameter declaration - PsiWhiteSpace('\n') PsiElement(RPAR)(')') PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/trailingCommaAllowed.kt b/compiler/testData/psi/trailingCommaAllowed.kt new file mode 100644 index 00000000000..51f043b663c --- /dev/null +++ b/compiler/testData/psi/trailingCommaAllowed.kt @@ -0,0 +1,157 @@ +class A( + val x: String, + val y: String, +) { + constructor( + x: Comparable>, + y: Iterable> , + ) {} + + var x: Int + get() = 10 + set(value,) { + + } + + var x: Int + get() = 10 + set(value,/*...*/) { + + } + + var x: Int + get() = 10 + set(value/*...*/,) { + + } +} + +fun foo( + x: Int, + y: Number + , +) {} + +val foo: (Int, Int) -> Int = fun(x, + y, ): Int { + return x + y +} + +val foo: (Int, Int, Int) -> Int = + fun (x, + y: Int, z, + ): Int { + return x + y + } + +fun foo() = listOf( + foo.bar.something(), + "foo bar something" + , + ) + +fun foo() { + val x = x[ + 1, + 3 + , ] + val y = x[ + 1, + 3 + , + ] +} + +fun main() { + val x = { + x: Comparable>, + y: Iterable> + ,-> + println("1") + } + val y = { + x: Comparable>, + y: Iterable>, + -> println("1") + } + val z = { + x: Comparable>, + y: Iterable> + , + -> + println("1") + } +} + +fun foo(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class, + -> println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class,-> + println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class + , + -> + println(1) + else -> println(3) +} + +@Anno([1, 2, 3, 4 + ,] +) +fun foo() {} + +fun main() { + val ( + y, + z, + ) = Pair(1, 2) + val ( + y, + z + , ) = Pair(1, 2) +} + +class A< + T1: Number, + T2: Iterable>>, + T3: Comparable>>, + > { } + +fun < + T1: Comparable>, + T2: Iterable> + , + > foo() {} + +fun main() { + foo>, Iterable>,>() +} + +fun main() { + val x: ( + y: Comparable>, + z: Iterable>, + ) -> Int = { 10 } + + val y = foo(1,) {} + + try { + println(1) + } catch (e: Exception,) { + + } +} diff --git a/compiler/testData/psi/trailingCommaAllowed.txt b/compiler/testData/psi/trailingCommaAllowed.txt new file mode 100644 index 00000000000..f1b15ee0748 --- /dev/null +++ b/compiler/testData/psi/trailingCommaAllowed.txt @@ -0,0 +1,1537 @@ +KtFile: trailingCommaAllowed.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + SECONDARY_CONSTRUCTOR + PsiElement(constructor)('constructor') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + CONSTRUCTOR_DELEGATION_CALL + CONSTRUCTOR_DELEGATION_REFERENCE + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiElement(COMMA)(',') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiElement(COMMA)(',') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(COMMA)(',') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUN + PsiElement(fun)('fun') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('z') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('listOf') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('foo bar something') + PsiElement(CLOSING_QUOTE)('"') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('main') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + BLOCK + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('1') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + BLOCK + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('1') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('z') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + BLOCK + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('1') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Anno') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + COLLECTION_LITERAL_EXPRESSION + PsiElement(LBRACKET)('[') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('4') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('main') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('y') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('z') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Pair') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('y') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('z') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Pair') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + PsiWhiteSpace('\n ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T3') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + PsiWhiteSpace('\n ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('main') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('main') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('z') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BLOCK + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_ARGUMENT + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + TRY + PsiElement(try)('try') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + CATCH + PsiElement(catch)('catch') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('e') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Exception') + PsiElement(COMMA)(',') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/trailingCommaForbidden.kt b/compiler/testData/psi/trailingCommaForbidden.kt new file mode 100644 index 00000000000..7f7732510b8 --- /dev/null +++ b/compiler/testData/psi/trailingCommaForbidden.kt @@ -0,0 +1,109 @@ +class A: A1, A2, { } + +class A where + T1: Comparable>, + T2: Iterable>, { } + +class A( + val x: String, + val y: String,, + ) { + constructor(,) {} +} + +fun foo( + x: Int, + y: Number + , + , + ) {} + +fun foo() = listOf( + foo.bar.something(), + "foo bar something", + , + ) + +fun foo() = listOf( + foo.bar.something(), + ,"foo bar something") + +fun foo() = listOf( + foo.bar.something(), + ,"foo bar something", + ) + +fun foo() { + val x = x[ + 1, + 3, + ,] + val y = x[,] + val z1 = x[,1] + val z2 = x[,,1] + val z3 = x[,1,] +} + +fun main() { + val x = { x: Comparable>, + y: Iterable>, + , -> + println("1") + } + val y = { , -> + println("1") + } + val () = Pair(1,2) + val (,) = Pair(1,2) +} + +fun foo(x: Any) = when (x) { + Comparable::class, + Iterable::class, + String::class, + , + -> println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + ,Comparable::class, + -> println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + ,Comparable::class -> println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + , -> println(1) + else -> println(3) +} + +fun foo(x: Any) = when (x) { + true -> println(1) + else, -> println(3) +} + +fun foo(x: Any) = when (x) { + true, ,-> println(1) + else -> println(3) +} + +fun foo() = foo(,) {} + +fun foo() = foo {}, + +fun foo() = foo(1) {}, + +fun foo10() { + fun > foo10() {} +} + +fun foo() = when (x) { + 1,, -> null +} + +fun foo() {} diff --git a/compiler/testData/psi/trailingCommaForbidden.txt b/compiler/testData/psi/trailingCommaForbidden.txt new file mode 100644 index 00000000000..c09fbb67b9c --- /dev/null +++ b/compiler/testData/psi/trailingCommaForbidden.txt @@ -0,0 +1,1289 @@ +KtFile: trailingCommaForbidden.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + SUPER_TYPE_LIST + SUPER_TYPE_ENTRY + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + SUPER_TYPE_ENTRY + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A2') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + SUPER_TYPE_ENTRY + TYPE_REFERENCE + PsiErrorElement:Type expected + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T2') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(where)('where') + PsiWhiteSpace('\n ') + TYPE_CONSTRAINT_LIST + TYPE_CONSTRAINT + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T1') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + TYPE_CONSTRAINT + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T2') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_CONSTRAINT + PsiErrorElement:Expecting type parameter name + + TYPE_REFERENCE + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('A') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COMMA)(',') + PsiErrorElement:Expecting a parameter declaration + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiErrorElement:Parameter name expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + SECONDARY_CONSTRUCTOR + PsiElement(constructor)('constructor') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a parameter declaration + PsiElement(COMMA)(',') + VALUE_PARAMETER + PsiErrorElement:Parameter name expected + + PsiElement(RPAR)(')') + CONSTRUCTOR_DELEGATION_CALL + CONSTRUCTOR_DELEGATION_REFERENCE + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting a parameter declaration + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiErrorElement:Parameter name 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)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('listOf') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('foo bar something') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting an argument + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('listOf') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting an argument + PsiElement(COMMA)(',') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('foo bar something') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('listOf') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting an argument + PsiElement(COMMA)(',') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('foo bar something') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting an index element + PsiElement(COMMA)(',') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiErrorElement:Expecting an index element + PsiElement(COMMA)(',') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('z1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiErrorElement:Expecting an index element + PsiElement(COMMA)(',') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('z2') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiErrorElement:Expecting an index element + PsiElement(COMMA)(',') + PsiErrorElement:Expecting an expression + + PsiElement(COMMA)(',') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('z3') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + INDICES + PsiElement(LBRACKET)('[') + PsiErrorElement:Expecting an index element + PsiElement(COMMA)(',') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('main') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiErrorElement:Expecting parameter name + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + BLOCK + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('1') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + BLOCK + PsiErrorElement:Expecting an element + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('1') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a name + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Pair') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + DESTRUCTURING_DECLARATION + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a name + PsiElement(COMMA)(',') + DESTRUCTURING_DECLARATION_ENTRY + PsiErrorElement:Expecting a name + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Pair') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Iterable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('String') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + WHEN_CONDITION_WITH_EXPRESSION + PsiErrorElement:Expecting an expression, is-condition or in-condition + + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + WHEN_CONDITION_WITH_EXPRESSION + CLASS_LITERAL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + PsiElement(COLONCOLON)('::') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + WHEN_CONDITION_WITH_EXPRESSION + PsiErrorElement:Expecting an expression, is-condition or in-condition + + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiErrorElement:Expecting '->' + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + WHEN_CONDITION_WITH_EXPRESSION + PsiErrorElement:Expecting an expression, is-condition or in-condition + + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHEN_ENTRY + PsiElement(else)('else') + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiErrorElement:Expecting an argument + PsiElement(COMMA)(',') + VALUE_ARGUMENT + PsiErrorElement:Expecting an expression + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_ARGUMENT + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + LAMBDA_ARGUMENT + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiErrorElement:Expecting a top level declaration + PsiElement(COMMA)(',') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_ARGUMENT + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiErrorElement:Expecting a top level declaration + PsiElement(COMMA)(',') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiErrorElement:Type parameter declaration expected + + PsiWhiteSpace(' ') + PsiErrorElement:Missing '>' + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Number') + PsiErrorElement:Expecting '(' + + PsiErrorElement:Expecting a top level declaration + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiErrorElement:Expecting a top level declaration + PsiElement(IDENTIFIER)('foo10') + PsiErrorElement:Expecting a top level declaration + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a top level declaration + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + FUN + PsiErrorElement:Expecting a top level declaration + + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T1') + PsiElement(COMMA)(',') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T2') + PsiElement(COMMA)(',') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T3') + PsiElement(COMMA)(',') + PsiErrorElement:Type parameter declaration expected + + PsiErrorElement:Missing '>' + PsiElement(COLON)(':') + PsiElement(IDENTIFIER)('Comparable') + PsiErrorElement:Only one type parameter list is allowed for a function + PsiElement(LT)('<') + PsiElement(IDENTIFIER)('Int') + PsiElement(GT)('>') + PsiErrorElement:Expecting '(' + + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo10') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + LAMBDA_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + WHEN + PsiElement(when)('when') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_WITH_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiErrorElement:Expecting a when-condition + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + WHEN_CONDITION_WITH_EXPRESSION + PsiErrorElement:Expecting an expression, is-condition or in-condition + + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T1') + PsiElement(COMMA)(',') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T2') + PsiElement(COMMA)(',') + PsiErrorElement:Expecting type parameter declaration + PsiElement(COMMA)(',') + PsiErrorElement:Type parameter declaration expected + + PsiElement(GT)('>') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 053a1c62a92..0b96f39a618 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -3392,6 +3392,84 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractDiagnosticsTestWithStdLib { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/trailingComma"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("multiVariableDeclarationWithDisabledFeature.kt") + public void testMultiVariableDeclarationWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt"); + } + + @TestMetadata("multiVariableDeclarationWithEnabledFeature.kt") + public void testMultiVariableDeclarationWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt"); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt"); + } + + @TestMetadata("typeArgumentsWithDisabledFeature.kt") + public void testTypeArgumentsWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt"); + } + + @TestMetadata("typeArgumentsWithEnabledFeature.kt") + public void testTypeArgumentsWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt"); + } + + @TestMetadata("typeParametersWithDisabledFeature.kt") + public void testTypeParametersWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt"); + } + + @TestMetadata("typeParametersWithEnabledFeature.kt") + public void testTypeParametersWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt"); + } + + @TestMetadata("valueArgumentsWithDisabledFeature.kt") + public void testValueArgumentsWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt"); + } + + @TestMetadata("valueArgumentsWithEnabledFeature.kt") + public void testValueArgumentsWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt"); + } + + @TestMetadata("valueParametersWithDisabledFeature.kt") + public void testValueParametersWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt"); + } + + @TestMetadata("valueParametersWithEnabledFeature.kt") + public void testValueParametersWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt"); + } + + @TestMetadata("whenEntryWithDisabledFeature.kt") + public void testWhenEntryWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt"); + } + + @TestMetadata("whenEntryWithEnabledFeature.kt") + public void testWhenEntryWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt"); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/tryCatch") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 2516ed502d5..d1a83bd2386 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -3392,6 +3392,84 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractDiagnosticsTestWithStdLibUsingJavac { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/trailingComma"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("multiVariableDeclarationWithDisabledFeature.kt") + public void testMultiVariableDeclarationWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithDisabledFeature.kt"); + } + + @TestMetadata("multiVariableDeclarationWithEnabledFeature.kt") + public void testMultiVariableDeclarationWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/multiVariableDeclarationWithEnabledFeature.kt"); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/noDisambiguation.kt"); + } + + @TestMetadata("typeArgumentsWithDisabledFeature.kt") + public void testTypeArgumentsWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithDisabledFeature.kt"); + } + + @TestMetadata("typeArgumentsWithEnabledFeature.kt") + public void testTypeArgumentsWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeArgumentsWithEnabledFeature.kt"); + } + + @TestMetadata("typeParametersWithDisabledFeature.kt") + public void testTypeParametersWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt"); + } + + @TestMetadata("typeParametersWithEnabledFeature.kt") + public void testTypeParametersWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt"); + } + + @TestMetadata("valueArgumentsWithDisabledFeature.kt") + public void testValueArgumentsWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithDisabledFeature.kt"); + } + + @TestMetadata("valueArgumentsWithEnabledFeature.kt") + public void testValueArgumentsWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueArgumentsWithEnabledFeature.kt"); + } + + @TestMetadata("valueParametersWithDisabledFeature.kt") + public void testValueParametersWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.kt"); + } + + @TestMetadata("valueParametersWithEnabledFeature.kt") + public void testValueParametersWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt"); + } + + @TestMetadata("whenEntryWithDisabledFeature.kt") + public void testWhenEntryWithDisabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithDisabledFeature.kt"); + } + + @TestMetadata("whenEntryWithEnabledFeature.kt") + public void testWhenEntryWithEnabledFeature() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/trailingComma/whenEntryWithEnabledFeature.kt"); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/tryCatch") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 2001f8288b9..92bef77af26 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -26580,6 +26580,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/trailingComma"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/codegen/box/trailingComma/noDisambiguation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/traits") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d58b4691b6d..01faaa8805d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -25397,6 +25397,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/trailingComma"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/codegen/box/trailingComma/noDisambiguation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/traits") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 36df8857fce..d7a43de85d5 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -25414,6 +25414,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/trailingComma"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/codegen/box/trailingComma/noDisambiguation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/traits") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java index d21504350cb..512d18e56fa 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java @@ -380,11 +380,6 @@ public class ParsingTestGenerated extends AbstractParsingTest { runTest("compiler/testData/psi/FunctionTypes.kt"); } - @TestMetadata("FunctionTypes_ERR.kt") - public void testFunctionTypes_ERR() throws Exception { - runTest("compiler/testData/psi/FunctionTypes_ERR.kt"); - } - @TestMetadata("Functions.kt") public void testFunctions() throws Exception { runTest("compiler/testData/psi/Functions.kt"); @@ -645,6 +640,16 @@ public class ParsingTestGenerated extends AbstractParsingTest { runTest("compiler/testData/psi/Super.kt"); } + @TestMetadata("trailingCommaAllowed.kt") + public void testTrailingCommaAllowed() throws Exception { + runTest("compiler/testData/psi/trailingCommaAllowed.kt"); + } + + @TestMetadata("trailingCommaForbidden.kt") + public void testTrailingCommaForbidden() throws Exception { + runTest("compiler/testData/psi/trailingCommaForbidden.kt"); + } + @TestMetadata("TraitConstructor.kt") public void testTraitConstructor() throws Exception { runTest("compiler/testData/psi/TraitConstructor.kt"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 5b32f65b715..434c9094b78 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -111,6 +111,7 @@ enum class LanguageFeature( ProhibitTailrecOnVirtualMember(KOTLIN_1_4, kind = BUG_FIX), ProperComputationOrderOfTailrecDefaultParameters(KOTLIN_1_4), AllowNullableArrayArgsInMain(KOTLIN_1_4), + TrailingCommas(KOTLIN_1_4), ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX), // Temporarily disabled, see KT-27084/KT-22379 diff --git a/idea/testData/indentationOnNewline/NotFirstParameter.after.kt b/idea/testData/indentationOnNewline/NotFirstParameter.after.kt index 5143bac94d3..ca3281b5838 100644 --- a/idea/testData/indentationOnNewline/NotFirstParameter.after.kt +++ b/idea/testData/indentationOnNewline/NotFirstParameter.after.kt @@ -1,3 +1,3 @@ fun testParam(a : String, b : Int, - ) { +) { } \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt b/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt index affa3bd5d4e..be3008b621d 100644 --- a/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt +++ b/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.inv.kt @@ -1,6 +1,6 @@ fun test() { testVeryLong(12, - ) + ) } // SET_TRUE: ALIGN_MULTILINE_PARAMETERS_IN_CALLS \ No newline at end of file diff --git a/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt b/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt index f396effb050..be3008b621d 100644 --- a/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt +++ b/idea/testData/indentationOnNewline/SettingAlignMultilineParametersInCalls.after.kt @@ -1,6 +1,6 @@ fun test() { testVeryLong(12, - ) + ) } // SET_TRUE: ALIGN_MULTILINE_PARAMETERS_IN_CALLS \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/mismatchingArgs/notForIncompleteCall.test b/idea/testData/quickfix/autoImports/mismatchingArgs/notForIncompleteCall.test index 5895fbce557..d58f378c8d3 100644 --- a/idea/testData/quickfix/autoImports/mismatchingArgs/notForIncompleteCall.test +++ b/idea/testData/quickfix/autoImports/mismatchingArgs/notForIncompleteCall.test @@ -1,5 +1,6 @@ // FILE: first.before.kt // "Import" "false" +// ERROR: The feature "trailing commas" is only available since language version 1.4 // ERROR: Type mismatch: inferred type is Int but String was expected // ACTION: Add 'toString()' call // ACTION: Change parameter 'p' type of function 'foo' to 'Int' diff --git a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt index f2266ba057b..215c01a3b1c 100644 --- a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt +++ b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt @@ -1,4 +1,5 @@ // "Create property 'foo' as constructor parameter" "true" +// ERROR: The feature "trailing commas" is only available since language version 1.4 // ERROR: No value passed for parameter 'foo' class A(val n: T) diff --git a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt.after b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt.after index dcd78066462..7e4e11a0dfd 100644 --- a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt.after +++ b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/valOnUserType.kt.after @@ -1,4 +1,5 @@ // "Create property 'foo' as constructor parameter" "true" +// ERROR: The feature "trailing commas" is only available since language version 1.4 // ERROR: No value passed for parameter 'foo' class A(val n: T, val foo: A) diff --git a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt index f38dd2f3c94..455ddddf6f8 100644 --- a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt +++ b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt @@ -1,4 +1,5 @@ // "Create property 'foo' as constructor parameter" "true" +// ERROR: The feature "trailing commas" is only available since language version 1.4 // ERROR: No value passed for parameter 'foo' class A(val n: T) diff --git a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt.after b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt.after index b60e43e86b8..de09bd964e6 100644 --- a/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt.after +++ b/idea/testData/quickfix/createFromUsage/createVariable/primaryParameter/varOnUserType.kt.after @@ -1,4 +1,5 @@ // "Create property 'foo' as constructor parameter" "true" +// ERROR: The feature "trailing commas" is only available since language version 1.4 // ERROR: No value passed for parameter 'foo' class A(val n: T, var foo: String) diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt index c1b55abc7a0..e44f52aed10 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/TypedHandlerTest.kt @@ -782,7 +782,7 @@ class TypedHandlerTest : LightCodeInsightTestCase() { """ |class A( | a: Int, - | + | |) """, enableSmartEnterWithTabs() @@ -800,7 +800,7 @@ class TypedHandlerTest : LightCodeInsightTestCase() { """ |fun method( | arg1: String, - | + | |) {} """, enableSmartEnterWithTabs() diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index e667e1043ca..07784190aeb 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -20590,6 +20590,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/trailingComma"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/codegen/box/trailingComma/noDisambiguation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/traits") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index ce603614a96..07d06a55e28 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -21700,6 +21700,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/trailingComma") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TrailingComma extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInTrailingComma() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/trailingComma"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("noDisambiguation.kt") + public void testNoDisambiguation() throws Exception { + runTest("compiler/testData/codegen/box/trailingComma/noDisambiguation.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/traits") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)