From 7f02d57d88f186184016ee82ae2e5a8656367451 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 16 Apr 2020 17:46:18 +0300 Subject: [PATCH] [FIR] Correctly detect super type in delegated constructor call --- .../constructors/noSuperCallInSupertypes.kt | 27 +++++ .../constructors/noSuperCallInSupertypes.txt | 32 ++++++ .../resolve/defaultJavaImportHiding.txt | 2 +- .../resolve/diagnostics/notASupertype.txt | 2 +- .../resolve/expresssions/checkArguments.txt | 2 +- .../resolve/expresssions/genericDecorator.txt | 2 +- .../resolve/multifile/sealedStarImport.txt | 2 +- .../fir/FirDiagnosticsTestGenerated.java | 18 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 18 +++ .../FirExpressionsResolveTransformer.kt | 30 ++++- .../delegateConstructorCallWithKeywords.kt | 1 - .../codegen/box/classes/sealedInSameFile.kt | 1 - ...rCapturedInLambdaInSecondaryConstructor.kt | 1 - ...erConstructorCallInSecondaryConstructor.kt | 1 - .../clashingDefaultConstructors.kt | 1 - .../delegateWithComplexExpression.kt | 1 - .../box/secondaryConstructors/generics.kt | 1 - .../box/secondaryConstructors/localClasses.kt | 1 - .../superCallSecondary.kt | 1 - .../box/specialBuiltins/exceptionCause.kt | 1 - .../throwableImplWithSecondaryConstructor.kt | 1 - .../j+k/genericConstructor/superCall.fir.kt | 2 +- .../superCallImpossibleToInfer.fir.kt | 2 +- .../explicitConstructorDelegation.fir.kt | 4 +- .../diagnostics/tests/objects/Objects.fir.kt | 4 +- .../tests/resolve/HiddenDeclarations.fir.kt | 2 +- ...ctorArgumentsInSecondaryConstructor.fir.kt | 2 +- .../protectedVisibility/constructors.fir.kt | 4 +- .../constructorsInner.fir.kt | 19 ---- .../protectedVisibility/constructorsInner.kt | 1 + ...mentsResolveInBodyAndDelegationCall.fir.kt | 2 +- .../cyclicDelegationCalls.fir.kt | 2 +- .../errorsOnEmptyDelegationCall.fir.kt | 12 +- .../secondaryConstructors/generics.fir.kt | 8 +- .../secondaryConstructors/generics2.fir.kt | 4 +- .../secondaryConstructors/generics3.fir.kt | 12 +- ...seGenericFromInnerExtendingSameBase.fir.kt | 4 +- ...eGenericFromInnerExtendingSameBase2.fir.kt | 6 +- .../accessBaseWithSameExtension.fir.kt | 6 +- .../accessGenericBaseWithSameExtension.fir.kt | 8 +- .../headerCallChecker/operatorCall.fir.kt | 2 +- ...reportResolutionErrorOnImplicitOnce.fir.kt | 2 +- .../superSecondaryNonExisting.fir.kt | 2 +- .../varargsInDelegationCallToPrimary.fir.kt | 12 -- .../varargsInDelegationCallToPrimary.kt | 1 + .../varargsInDelegationCallToSecondary.fir.kt | 17 --- .../varargsInDelegationCallToSecondary.kt | 1 + .../valueParametersWithDisabledFeature.fir.kt | 4 +- .../valueParametersWithEnabledFeature.fir.kt | 104 ------------------ .../valueParametersWithEnabledFeature.kt | 1 + ...rderingInDelegatingConstructorCall.fir.txt | 17 ++- ...ructorCallsInSecondaryConstructors.fir.txt | 4 +- ...uctorWithInitializersFromClassBody.fir.txt | 6 +- .../expectClassInherited.fir.txt | 2 +- .../multiplatform/expectedSealedClass.fir.txt | 2 +- .../ir/irText/expressions/kt16904.fir.txt | 2 +- 56 files changed, 199 insertions(+), 230 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.txt delete mode 100644 compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.fir.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt b/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt new file mode 100644 index 0000000000000..57224d8d01f2e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt @@ -0,0 +1,27 @@ +// FILE: AJava.java + +public class AJava { + public AJava(String s) {} +} + +// FILE: main.kt + +class BJava : AJava, C { + constructor(s: String) : super(s) +} + +open class AKt(val s: String) + +class BKt : AKt, C { + constructor(s: String) : super(s) +} + +interface C + +typealias QQQ = AKt + +typealias DDD = C + +class CKt : QQQ, DDD { + constructor(s: String) : super(s) +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.txt b/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.txt new file mode 100644 index 0000000000000..9e77dfbb44080 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.txt @@ -0,0 +1,32 @@ +FILE: main.kt + public final class BJava : R|AJava|, R|C| { + public constructor(s: R|kotlin/String|): R|BJava| { + super(R|/s|) + } + + } + public open class AKt : R|kotlin/Any| { + public constructor(s: R|kotlin/String|): R|AKt| { + super() + } + + public final val s: R|kotlin/String| = R|/s| + public get(): R|kotlin/String| + + } + public final class BKt : R|AKt|, R|C| { + public constructor(s: R|kotlin/String|): R|BKt| { + super(R|/s|) + } + + } + public abstract interface C : R|kotlin/Any| { + } + public final typealias QQQ = R|AKt| + public final typealias DDD = R|C| + public final class CKt : R|QQQ|, R|DDD| { + public constructor(s: R|kotlin/String|): R|CKt| { + super(R|/s|) + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/defaultJavaImportHiding.txt b/compiler/fir/analysis-tests/testData/resolve/defaultJavaImportHiding.txt index 5b27f60e8a74d..9d61b0d4d253e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/defaultJavaImportHiding.txt +++ b/compiler/fir/analysis-tests/testData/resolve/defaultJavaImportHiding.txt @@ -8,7 +8,7 @@ FILE: LinkedList.kt FILE: HashSet.kt public final class HashSet : R|java/util/HashSet| { public constructor(): R|util/HashSet| { - super() + super|>() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.txt index 5e174020775ba..5d41a0582e0d4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.txt @@ -10,7 +10,7 @@ FILE: notASupertype.kt } public final class B : R|A| { public constructor(): R|B| { - super() + super() } public final fun g(): R|kotlin/Unit| { diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/checkArguments.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/checkArguments.txt index 4c94362660fef..64f02dbdcfe32 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/checkArguments.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/checkArguments.txt @@ -13,7 +13,7 @@ FILE: checkArguments.kt } public final class C : R|B| { public constructor(): R|C| { - super() + super() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDecorator.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDecorator.txt index e158b5aaf6a8a..ff7bfcfc6f125 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDecorator.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDecorator.txt @@ -1,7 +1,7 @@ FILE: test.kt public final class MyDecorator : R|Decorator| { public constructor(): R|MyDecorator| { - super() + super|>() } public final override fun getLookupString(): R|kotlin/String| { diff --git a/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.txt b/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.txt index bf8d0dee1b421..bcf1b06837ccf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.txt +++ b/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.txt @@ -13,7 +13,7 @@ FILE: test.kt public final class Extra : R|test/Test| { public constructor(x: R|kotlin/Int|): R|test/Test.Extra| { - super() + super() } public final val x: R|kotlin/Int| = R|/x| diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index e6e77cc897e78..422be426af698 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -723,6 +723,24 @@ public void testWhen() throws Exception { } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Constructors extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInConstructors() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/constructors"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("noSuperCallInSupertypes.kt") + public void testNoSuperCallInSupertypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index cffc32f8c438f..f288827ccbbe9 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -723,6 +723,24 @@ public void testWhen() throws Exception { } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Constructors extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInConstructors() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/constructors"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("noSuperCallInSupertypes.kt") + public void testNoSuperCallInSupertypes() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/constructors/noSuperCallInSupertypes.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/delegates") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 80790d911f39e..3ba9fdd054652 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve import com.intellij.openapi.progress.ProcessCanceledException +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.* -import org.jetbrains.kotlin.fir.declarations.FirTypeParameter -import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner +import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeStubDiagnostic @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.expressions.builder.buildVariableAssignment import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference +import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* @@ -25,6 +26,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.candidate import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer import org.jetbrains.kotlin.fir.resolve.transformers.StoreReceiver +import org.jetbrains.kotlin.fir.resolve.transformers.firClassLike import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol @@ -604,6 +606,21 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : when (delegatedConstructorCall.calleeReference) { is FirResolvedNamedReference, is FirErrorNamedReference -> return delegatedConstructorCall.compose() } + if (delegatedConstructorCall.isSuper && delegatedConstructorCall.constructedTypeRef is FirImplicitTypeRef) { + val containers = components.context.containers + val containingClass = containers[containers.lastIndex - 1] as FirClass<*> + val superClass = containingClass.superTypeRefs.firstOrNull { + if (it !is FirResolvedTypeRef) return@firstOrNull false + val declaration = extractSuperTypeDeclaration(it) ?: return@firstOrNull false + declaration.classKind == ClassKind.CLASS + } as FirResolvedTypeRef? ?: session.builtinTypes.anyType + delegatedConstructorCall.replaceConstructedTypeRef(superClass) + delegatedConstructorCall.replaceCalleeReference(buildExplicitSuperReference { + source = delegatedConstructorCall.calleeReference.source + superTypeRef = superClass + }) + } + dataFlowAnalyzer.enterCall(delegatedConstructorCall) var callCompleted = true var result = delegatedConstructorCall @@ -661,6 +678,15 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } } + private fun extractSuperTypeDeclaration(typeRef: FirTypeRef): FirRegularClass? { + if (typeRef !is FirResolvedTypeRef) return null + return when (val declaration = typeRef.firClassLike(session)) { + is FirRegularClass -> declaration + is FirTypeAlias -> extractSuperTypeDeclaration(declaration.expandedTypeRef) + else -> null + } + } + @OptIn(ExperimentalStdlibApi::class) override fun transformAugmentedArraySetCall(augmentedArraySetCall: FirAugmentedArraySetCall, data: ResolutionMode): CompositeTransformResult { assert(augmentedArraySetCall.operation in FirOperation.ASSIGNMENTS) diff --git a/compiler/testData/codegen/box/classes/delegateConstructorCallWithKeywords.kt b/compiler/testData/codegen/box/classes/delegateConstructorCallWithKeywords.kt index 42483df686618..37d32d3d1902d 100644 --- a/compiler/testData/codegen/box/classes/delegateConstructorCallWithKeywords.kt +++ b/compiler/testData/codegen/box/classes/delegateConstructorCallWithKeywords.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A(val x: String) { constructor(`in`: String, y: String) : this(`in` + y) diff --git a/compiler/testData/codegen/box/classes/sealedInSameFile.kt b/compiler/testData/codegen/box/classes/sealedInSameFile.kt index c62831ca44370..673afef28ef8c 100644 --- a/compiler/testData/codegen/box/classes/sealedInSameFile.kt +++ b/compiler/testData/codegen/box/classes/sealedInSameFile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class B : A() sealed class A() { diff --git a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInLambdaInSecondaryConstructor.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInLambdaInSecondaryConstructor.kt index 2867d3c996647..925f6840dc7f2 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInLambdaInSecondaryConstructor.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInLambdaInSecondaryConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class Base(val callback: () -> String) class Outer { diff --git a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt index 36776de2ffe5f..21fffac8e8eb1 100644 --- a/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt +++ b/compiler/testData/codegen/box/inlineClasses/hiddenConstructor/delegatingSuperConstructorCallInSecondaryConstructor.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR inline class S(val string: String) diff --git a/compiler/testData/codegen/box/secondaryConstructors/clashingDefaultConstructors.kt b/compiler/testData/codegen/box/secondaryConstructors/clashingDefaultConstructors.kt index 67f36d5a623f9..bad07d0d16b58 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/clashingDefaultConstructors.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/clashingDefaultConstructors.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A(val x: String = "abc", val y: String = "efg") { constructor(x: String, y: String, z: Int): this(x, y + "#" + z.toString()) diff --git a/compiler/testData/codegen/box/secondaryConstructors/delegateWithComplexExpression.kt b/compiler/testData/codegen/box/secondaryConstructors/delegateWithComplexExpression.kt index 7828742a1b94e..999d944d7f1df 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/delegateWithComplexExpression.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/delegateWithComplexExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR var log = "" open class Base(val s: String) diff --git a/compiler/testData/codegen/box/secondaryConstructors/generics.kt b/compiler/testData/codegen/box/secondaryConstructors/generics.kt index c1e3a0fb5cbb4..a025954f6ddf2 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/generics.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/generics.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR internal open class B(val x: T, val y: T) { constructor(x: T): this(x, x) override fun toString() = "$x#$y" diff --git a/compiler/testData/codegen/box/secondaryConstructors/localClasses.kt b/compiler/testData/codegen/box/secondaryConstructors/localClasses.kt index f10e7695e1157..fb26a6ba6aa45 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/localClasses.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/localClasses.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class C(val grandParentProp: String) fun box(): String { var sideEffects: String = "" diff --git a/compiler/testData/codegen/box/secondaryConstructors/superCallSecondary.kt b/compiler/testData/codegen/box/secondaryConstructors/superCallSecondary.kt index fc0485c7f745e..e5d0064aa0107 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/superCallSecondary.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/superCallSecondary.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR var sideEffects: String = "" internal abstract class B { diff --git a/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt b/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt index 9fa2a90e0c8b7..cd0501bdf1daf 100644 --- a/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt +++ b/compiler/testData/codegen/box/specialBuiltins/exceptionCause.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class CustomException : Throwable { constructor(message: String?, cause: Throwable?) : super(message, cause) diff --git a/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt b/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt index da4c2fbef34ec..afa627c459891 100644 --- a/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt +++ b/compiler/testData/codegen/box/specialBuiltins/throwableImplWithSecondaryConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class MyThrowable : Throwable { val x: String diff --git a/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCall.fir.kt b/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCall.fir.kt index 660e860c34757..9cd1000405eed 100644 --- a/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCall.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCall.fir.kt @@ -13,6 +13,6 @@ class B1(x: List) : A("", x) class B2(x: List) : A("", x) class C : A { - constructor(x: List) : super("", x) + constructor(x: List) : super("", x) constructor(x: List, y: Int) : super("", x) } diff --git a/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCallImpossibleToInfer.fir.kt b/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCallImpossibleToInfer.fir.kt index ce34660267130..a5fb8aabaed74 100644 --- a/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCallImpossibleToInfer.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/genericConstructor/superCallImpossibleToInfer.fir.kt @@ -16,6 +16,6 @@ class B1(x: List) : A("", x) class B2(x: List) : A("", x) class C : A { - constructor(x: List) : super("", x) + constructor(x: List) : super("", x) constructor(x: List, y: Int) : super("", x) } diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt index c5b897ca5dbdb..94dbc558730f1 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt @@ -8,7 +8,7 @@ expect open class A { } expect class B : A { - constructor(i: Int) + constructor(i: Int) - constructor() : super("B") + constructor() : super("B") } diff --git a/compiler/testData/diagnostics/tests/objects/Objects.fir.kt b/compiler/testData/diagnostics/tests/objects/Objects.fir.kt index c417e1904c569..fcaee4376e2bf 100644 --- a/compiler/testData/diagnostics/tests/objects/Objects.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/Objects.fir.kt @@ -4,9 +4,9 @@ package toplevelObjectDeclarations open fun foo() : Int = 1 } - class T : Foo {} + class T : Foo {} - object A : Foo { + object A : Foo { val x : Int = 2 fun test() : Int { diff --git a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt index 153352100f957..6dc7b1e069235 100644 --- a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.fir.kt @@ -70,5 +70,5 @@ class B : A("") { } class C : A { - constructor() : super("") + constructor() : super("") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt index d8af76026be71..065b7f95d9cd8 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt @@ -14,7 +14,7 @@ open class S( class A : S { - constructor() : super( + constructor() : super( foo(), Nested(), Inner(), diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt index bdb52a79479a1..4793101a9cf7d 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt @@ -16,7 +16,7 @@ class B2 : A() {} class B3 : A("") {} class B4 : A { - constructor() : super(1) + constructor() : super(1) constructor(x: Int) : super() - constructor(x: Int, y: Int) : super("") + constructor(x: Int, y: Int) : super("") } diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.fir.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.fir.kt deleted file mode 100644 index d2fdff585a6b9..0000000000000 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.fir.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -open class Outer { - inner open class A protected constructor(x: Int) { - protected constructor() : this(1) - - protected constructor(x: String) : this(2) - } - - inner class B1 : A(1) {} - inner class B2 : A() {} - inner class B3 : A("") {} - - inner class B4 : A { - constructor() : super(1) - constructor(x: Int) : super() - constructor(x: Int, y: Int) : super("") - } -} - diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt index 5c7bc221ee52e..9d5e16ab50d9e 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructorsInner.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class Outer { inner open class A protected constructor(x: Int) { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/argumentsResolveInBodyAndDelegationCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/argumentsResolveInBodyAndDelegationCall.fir.kt index b7444d2bdafc0..2ea8712605710 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/argumentsResolveInBodyAndDelegationCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/argumentsResolveInBodyAndDelegationCall.fir.kt @@ -5,7 +5,7 @@ class A : B { val myProp: Int = 1 override val parentProp = 1 - constructor(x: Int, y: Int = global): super(x + y + global) { + constructor(x: Int, y: Int = global): super(x + y + global) { foo(x, y, myProp) x + y + myProp + parentProp + super.parentProp } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.fir.kt index f96d9d0191b4f..e18880f508996 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.fir.kt @@ -35,5 +35,5 @@ class A : B { // no cycle, just call to super constuctor constructor(x1: Double, x2: Double): this(x1, x2, 1.0) constructor(x1: Double, x2: Double, x3: Double): this(x1, x2, x3, 1.0) - constructor(x1: Double, x2: Double, x3: Double, x4: Double): super(1.toByte()) + constructor(x1: Double, x2: Double, x3: Double, x4: Double): super(1.toByte()) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt index f3baa777222f2..adb9db90e3ee9 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt @@ -2,8 +2,8 @@ open class B0(x: Int) class A0 : B0 { - constructor() - constructor(x: Int) : super() + constructor() + constructor(x: Int) : super() } // -------------------------- @@ -26,8 +26,8 @@ open class B2 { } class A2 : B2 { - constructor() - constructor(x: Int) : super() + constructor() + constructor(x: Int) : super() } // -------------------------- @@ -37,6 +37,6 @@ open class B3 { } class A3 : B3 { - constructor() - constructor(x: Int) : super() + constructor() + constructor(x: Int) : super() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/generics.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/generics.fir.kt index 8dc957d4d5f5b..8477ffe92492a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/generics.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/generics.fir.kt @@ -6,14 +6,14 @@ open class B(x: T, y: T) { class A0 : B { constructor() - constructor(x: String): super(x) - constructor(x: String, y: String): super(x, y) + constructor(x: String): super(x) + constructor(x: String, y: String): super(x, y) } class A1 : B { constructor() - constructor(x: R): super(x) - constructor(x: R, y: R): super(x, y) + constructor(x: R): super(x) + constructor(x: R, y: R): super(x, y) } class A2 { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/generics2.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/generics2.fir.kt index e39d3bb67b1f6..d1e39c051a762 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/generics2.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/generics2.fir.kt @@ -13,14 +13,14 @@ class A0 { } class A1 : B { - constructor(x: T1, y: T2): super(x, y) + constructor(x: T1, y: T2): super(x, y) constructor(x: T1, y: Int): super(x, y) constructor(x: T1, y: T1, z: T1): super(x, y) } class A2 : B { constructor(x: T1, y: T2): super(x, y) - constructor(x: T1, y: Int): super(x, y) + constructor(x: T1, y: Int): super(x, y) constructor(x: T1, y: T1, z: T1): super(x, y) constructor(x: T1, y: T2, z: String): super(y, 1) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/generics3.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/generics3.fir.kt index d5466da6c22ec..81c591a7b4099 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/generics3.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/generics3.fir.kt @@ -6,11 +6,11 @@ open class B { } class A : B { - constructor(x: T1, y: T2): super(x, y) - constructor(x: T2, y: T2, z: String): super(x, y) + constructor(x: T1, y: T2): super(x, y) + constructor(x: T2, y: T2, z: String): super(x, y) - constructor(x: T2, z: String, z1: String): super(x, "") - constructor(x: T2, z: String, z1: String, z2: String): super(x, 1) - constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "") - constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): super(x, 1) + constructor(x: T2, z: String, z1: String): super(x, "") + constructor(x: T2, z: String, z1: String, z2: String): super(x, 1) + constructor(x: T1, z: String, z1: String, z2: String, z3: String): super(x, "") + constructor(x: T1, z: String, z1: String, z2: String, z3: String, z4: String): super(x, 1) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt index 4460d545f433f..d3a39f171e3a8 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt @@ -6,7 +6,7 @@ open class Base(p: Any?) { class D: Base("") { inner class B : Base { - constructor() : super(foo1("")) - constructor(x: Int) : super(foo1(1)) + constructor() : super(foo1("")) + constructor(x: Int) : super(foo1(1)) } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt index f80d80725cf3d..c4abe4fc71069 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt @@ -6,8 +6,8 @@ open class Base(p: Any?) { class D: Base(1) { inner class B : Base { - constructor() : super(foo1(1)) - constructor(x: Int) : super(this@B.foo1(1)) - constructor(x: Int, y: Int) : super(this@D.foo1(1)) + constructor() : super(foo1(1)) + constructor(x: Int) : super(this@B.foo1(1)) + constructor(x: Int, y: Int) : super(this@D.foo1(1)) } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt index 74f089f42d40c..ee862c5320e86 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt @@ -5,8 +5,8 @@ open class Base(p: Any?) { fun Base.foo() { class B : Base { - constructor() : super(foo1()) - constructor(x: Int) : super(this@foo.foo1()) - constructor(x: Int, y: Int) : super(this@B.foo1()) + constructor() : super(foo1()) + constructor(x: Int) : super(this@foo.foo1()) + constructor(x: Int, y: Int) : super(this@B.foo1()) } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt index b77e3cd6f82d5..ac7c5402a2dc1 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt @@ -5,9 +5,9 @@ open class Base(p: Any?) { fun Base.foo() { class B : Base { - constructor() : super(foo1("")) - constructor(x: Int) : super(foo1(1)) - constructor(x: Int, y: Int) : super(this@foo.foo1(12)) - constructor(x: Int, y: Int, z: Int) : super(this@B.foo1("")) + constructor() : super(foo1("")) + constructor(x: Int) : super(foo1(1)) + constructor(x: Int, y: Int) : super(this@foo.foo1(12)) + constructor(x: Int, y: Int, z: Int) : super(this@B.foo1("")) } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt index 0065247b64e55..6f999a9d56c82 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt @@ -1,7 +1,7 @@ open class C(val x: Int) class D : C { - constructor() : super( + constructor() : super( { val s = "" s() diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt index 85667e1cc22a4..6c9596db92bf6 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt @@ -2,5 +2,5 @@ open class A(p1: String, p2: String, p3: String, p4: String, p5: String) class B : A { - constructor(s: String) + constructor(s: String) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt index 76db3f69e6d71..8a039f7c21770 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt @@ -6,5 +6,5 @@ open class B(x: Double) { interface C class A : B, C { constructor(): super(' ') - constructor(x: Int) + constructor(x: Int) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.fir.kt deleted file mode 100644 index 5ade214712bb5..0000000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -fun array(vararg x: T): Array = null!! - -open class B(vararg y: String) { - constructor(x: Int): this(x.toString(), *array("1"), "2") -} - -class A : B { - constructor(x: String, y: String): super(x, *array("3"), y) - constructor(x: String): super(x) - constructor(): super() -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.kt index 837503019cf7a..f117fa5f6b9c8 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun array(vararg x: T): Array = null!! diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.fir.kt deleted file mode 100644 index 604684c9443eb..0000000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -fun array(vararg x: T): Array = null!! - -open class B(x: Int) { - constructor(vararg y: String): this(y[0].length) -} - -class A : B { - constructor(x: String, y: String): super(x, *array("q"), y) - constructor(x: String): super(x) - constructor(): super() -} - -val b1 = B() -val b2 = B("1", "2", "3") -val b3 = B("1", *array("2", "3"), "4") -val b4 = B(1) diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.kt index 61e925abad94d..7278c1534e44e 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToSecondary.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun array(vararg x: T): Array = null!! diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.fir.kt index 553dd90b15e1d..94418e5667d4a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithDisabledFeature.fir.kt @@ -60,13 +60,13 @@ open class Foo10(x: Int = 10, y: Float = 0f) class Foo11: Foo10 { constructor( x: Float - ): super(1, 1f,) + ): super(1, 1f,) } class Foo12: Foo10 { constructor( x: Float - ): super(1, 1f,/**/) + ): super(1, 1f,/**/) } fun main() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.fir.kt deleted file mode 100644 index 649e2491779fc..0000000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.fir.kt +++ /dev/null @@ -1,104 +0,0 @@ -// !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.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt index 40dc6bd5a9081..a63f8e3247965 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/valueParametersWithEnabledFeature.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER, -UNUSED_VARIABLE // !LANGUAGE: +TrailingCommas diff --git a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt index 9a16af2578497..86ef30ff2ee55 100644 --- a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt +++ b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt @@ -88,7 +88,14 @@ FILE fqName: fileName:/argumentReorderingInDelegatingConstructorCall.kt VALUE_PARAMETER name:xx index:0 type:kotlin.Int VALUE_PARAMETER name:yy index:1 type:kotlin.Int BLOCK_BODY - ERROR_CALL 'Cannot find delegated constructor call' type=kotlin.Any + BLOCK type=.Base origin=ARGUMENTS_REORDERING_FOR_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + GET_VAR 'yy: kotlin.Int declared in .Test2.' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + GET_VAR 'xx: kotlin.Int declared in .Test2.' type=kotlin.Int origin=null + DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int, y: kotlin.Int) [primary] declared in .Base' + x: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null + y: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.Base]' CONSTRUCTOR visibility:public <> (xxx:kotlin.Int, yyy:kotlin.Int, a:kotlin.Any) returnType:.Test2 VALUE_PARAMETER name:xxx index:0 type:kotlin.Int @@ -96,13 +103,13 @@ FILE fqName: fileName:/argumentReorderingInDelegatingConstructorCall.kt VALUE_PARAMETER name:a index:2 type:kotlin.Any BLOCK_BODY BLOCK type=.Test2 origin=ARGUMENTS_REORDERING_FOR_CALL - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] GET_VAR 'yyy: kotlin.Int declared in .Test2.' type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] GET_VAR 'xxx: kotlin.Int declared in .Test2.' type=kotlin.Int origin=null DELEGATING_CONSTRUCTOR_CALL 'public constructor (xx: kotlin.Int, yy: kotlin.Int) declared in .Test2' - xx: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null - yy: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null + xx: GET_VAR 'val tmp_5: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null + yy: GET_VAR 'val tmp_4: kotlin.Int [val] declared in .Test2.' type=kotlin.Int origin=null PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt index 4fec471895eed..adb2b637ce8d4 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt @@ -22,12 +22,12 @@ FILE fqName: fileName:/delegatingConstructorCallsInSecondaryConstructors.k $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test CONSTRUCTOR visibility:public <> () returnType:.Test BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.Base]' CONSTRUCTOR visibility:public <> (xx:kotlin.Int) returnType:.Test VALUE_PARAMETER name:xx index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.Base]' CONSTRUCTOR visibility:public <> (xx:kotlin.Short) returnType:.Test VALUE_PARAMETER name:xx index:0 type:kotlin.Short diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt index ae7fbf6932a57..4107a0ef868ff 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt +++ b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt @@ -33,7 +33,7 @@ FILE fqName: fileName:/secondaryConstructorWithInitializersFromClassBody.k receiver: GET_VAR ': .TestProperty declared in .TestProperty.' type=.TestProperty origin=null CONSTRUCTOR visibility:public <> () returnType:.TestProperty BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestProperty modality:FINAL visibility:public superTypes:[.Base]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -66,12 +66,12 @@ FILE fqName: fileName:/secondaryConstructorWithInitializersFromClassBody.k value: CONST Int type=kotlin.Int value=0 CONSTRUCTOR visibility:public <> () returnType:.TestInitBlock BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[.Base]' CONSTRUCTOR visibility:public <> (z:kotlin.Any) returnType:.TestInitBlock VALUE_PARAMETER name:z index:0 type:kotlin.Any BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[.Base]' CONSTRUCTOR visibility:public <> (y:kotlin.Int) returnType:.TestInitBlock VALUE_PARAMETER name:y index:0 type:kotlin.Int diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt index 1b9a6bc636fb9..eca948675cc42 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt @@ -25,7 +25,7 @@ FILE fqName: fileName:/expectClassInherited.kt CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:.B [primary] VALUE_PARAMETER name:i index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .A' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public [expect] superTypes:[.A]' FUN name:foo visibility:public modality:OPEN <> ($this:.B) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.B diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt index 4a5d659ca64d4..76abb775dbfc3 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt @@ -22,7 +22,7 @@ FILE fqName: fileName:/expectedSealedClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Add CONSTRUCTOR visibility:public <> () returnType:.Add [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Ops' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public [expect] superTypes:[.Ops]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/expressions/kt16904.fir.txt b/compiler/testData/ir/irText/expressions/kt16904.fir.txt index f307d4ea5b122..d63b5407a1dc0 100644 --- a/compiler/testData/ir/irText/expressions/kt16904.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt16904.fir.txt @@ -75,7 +75,7 @@ FILE fqName: fileName:/kt16904.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1 CONSTRUCTOR visibility:public <> () returnType:.Test1 BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.A]' CALL 'public final fun plusAssign (x: kotlin.Int): kotlin.Unit [operator] declared in .B' type=kotlin.Unit origin=null $this: CALL 'public final fun (): .B declared in .A' type=.B origin=GET_PROPERTY