diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index c24c63d9901..0f377326c14 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -849,6 +849,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/rawCastToStarProjection_Ok.kt"); } + @Test + @TestMetadata("receiverResolutionInDelegatedConstructor.kt") + public void testReceiverResolutionInDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt"); + } + @Test @TestMetadata("RecursiveResolve.kt") public void testRecursiveResolve() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index ee138cc2fd3..a539d412ccb 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -849,6 +849,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/rawCastToStarProjection_Ok.kt"); } + @Test + @TestMetadata("receiverResolutionInDelegatedConstructor.kt") + public void testReceiverResolutionInDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt"); + } + @Test @TestMetadata("RecursiveResolve.kt") public void testRecursiveResolve() throws Exception { diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt index 52f36df040d..43f056db648 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt @@ -1,6 +1,6 @@ FILE: instanceAccessBeforeSuperCall.kt public final class A : R|kotlin/Any| { - public constructor(x: R|kotlin/Int| = #(), other: R|A| = this@R|/A|, header: R|kotlin/String| = #): R|A| { + public constructor(x: R|kotlin/Int| = this@R|/A|.R|/A.getSomeInt#|(), other: R|A| = this@R|/A|, header: R|kotlin/String| = this@R|/A|.R|/A.keker#|): R|A| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt index 938fb425acb..bfd315083c5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt @@ -1,5 +1,5 @@ class A { - constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} + constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} fun getSomeInt() = 10 var keker = "test" } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 354291ada0a..8ca24c77de9 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -849,6 +849,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/rawCastToStarProjection_Ok.kt"); } + @Test + @TestMetadata("receiverResolutionInDelegatedConstructor.kt") + public void testReceiverResolutionInDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt"); + } + @Test @TestMetadata("RecursiveResolve.kt") public void testRecursiveResolve() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 71f8404b72a..d199a7a6c58 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -849,6 +849,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/rawCastToStarProjection_Ok.kt"); } + @Test + @TestMetadata("receiverResolutionInDelegatedConstructor.kt") + public void testReceiverResolutionInDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt"); + } + @Test @TestMetadata("RecursiveResolve.kt") public void testRecursiveResolve() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index d28a5d16955..5d9733b07a1 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -301,6 +301,8 @@ private fun mapInapplicableCandidateError( isError = rootCause.isError ) + is InaccessibleReceiver -> FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL.createOn(source, "") + else -> genericDiagnostic } }.distinct() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallKind.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallKind.kt index c07841982e4..617cbd98a30 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallKind.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallKind.kt @@ -24,6 +24,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) { LowerPriorityIfDynamic, ConstraintSystemForks, CheckIncompatibleTypeVariableUpperBounds, + InaccessibleReceiverResolutionStage, ) object SyntheticSelect : CallKind( @@ -59,6 +60,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) { LowerPriorityIfDynamic, ConstraintSystemForks, CheckIncompatibleTypeVariableUpperBounds, + InaccessibleReceiverResolutionStage, ) object DelegatingConstructorCall : CallKind( @@ -94,6 +96,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) { CheckIncompatibleTypeVariableUpperBounds, ProcessDynamicExtensionAnnotation, LowerPriorityIfDynamic, + InaccessibleReceiverResolutionStage, ) object SyntheticIdForCallableReferencesResolution : CallKind( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 3f29ca55bfc..aa4b7683fbc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -698,3 +698,14 @@ internal object ConstraintSystemForks : ResolutionStage() { } } } + +internal object InaccessibleReceiverResolutionStage : ResolutionStage() { + override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) { + if ( + candidate.dispatchReceiverValue is InaccessibleImplicitReceiverValue || + candidate.givenExtensionReceiverOptions.any { it is InaccessibleImplicitReceiverValue } + ) { + sink.yieldDiagnostic(InaccessibleReceiver) + } + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt index d31b0a1f71a..436ec1b2574 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt @@ -159,7 +159,7 @@ internal abstract class FirBaseTowerResolveTask( val receiver = lexical.implicitReceiver - if (receiver != null && receiver !is InaccessibleImplicitReceiverValue) { + if (receiver != null) { onImplicitReceiver(receiver, parentGroup.Implicit(depth)) } } diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt index 47ede463b10..0d2690cb674 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionDiagnostic.kt @@ -141,3 +141,5 @@ class NoApplicableValueForContextReceiver( class AmbiguousValuesForContextReceiverParameter( val expectedContextReceiverType: ConeKotlinType, ) : ResolutionDiagnostic(INAPPLICABLE) + +object InaccessibleReceiver : ResolutionDiagnostic(RESOLVED_WITH_ERROR) diff --git a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out index e0ffa7f5d1d..91b887e04d8 100644 --- a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out +++ b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out @@ -1,11 +1,11 @@ warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:26: error: unresolved reference: getSomeInt +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:26: error: cannot access '' before the instance has been initialized constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:51: error: cannot access '' before the instance has been initialized constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: unresolved reference: keker +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: cannot access '' before the instance has been initialized constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:7:20: error: 'this' is not defined in this context diff --git a/compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt b/compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt new file mode 100644 index 00000000000..b4c9b192345 --- /dev/null +++ b/compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt @@ -0,0 +1,36 @@ +// FIR_IDENTICAL +// ISSUE: KT-48870 + +open class Base(p: Any?) { + open fun foo1() {} +} + +class Vase(p: Any?) : Base(p) { + override fun foo1() {} +} + +fun Vase.test1() { + class B : Base { + // FIR: OK, it's this@foo.foo1() + // FE 1.0: INSTANCE_ACCESS_BEFORE_SUPER_CALL + constructor() : super(foo1()) + } +} + +fun Base.test2() { + class B : Base(foo1()) {} +} + +open class BaseLambda(lambda: () -> Any?) { + fun foo1() {} +} + +fun Base.test3() { + class B : Base { + constructor() : super({ foo1() }) + } +} + +fun Base.test4() { + class B : Base({ foo1() }) {} +} diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt deleted file mode 100644 index 19ca013a42d..00000000000 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt +++ /dev/null @@ -1,65 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -class A( - n: Nested = foo(), - n2: Nested = Nested(), - inn: Inner = null!!, - inn2: Inner = Inner(), - i: Interface = null!!, - c: Int = CONST, - cc: Int = Companion.CONST, - cn: Int = Nested.CONST, - ci: Int = Interface.CONST, - t1: Int = a, - t2: Int = b() -) { - - constructor( - dummy: Int, - n: Nested = foo(), - n2: Nested = Nested(), - inn: Inner = null!!, - inn2: Inner = Inner(), - i: Interface = null!!, - c: Int = CONST, - cc: Int = Companion.CONST, - cn: Int = Nested.CONST, - ci: Int = Interface.CONST, - t1: Int = a, - t2: Int = b() - ) : this( - foo(), - Nested(), - inn, - Inner(), - i, - CONST, - Companion.CONST, - Nested.CONST, - Interface.CONST, - a, - b() - ) - - class Nested { - companion object { - const val CONST = 2 - } - } - - inner class Inner - - interface Interface { - companion object { - const val CONST = 3 - } - } - - val a = 1 - fun b() = 2 - - companion object { - const val CONST = 1 - fun foo(): Nested = null!! - } -} diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.kt index b554c0708fe..41e8461d79b 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER class A( diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt index 2ee44e7e432..4eec60ca46c 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt @@ -17,13 +17,13 @@ class A : S { constructor() : super( foo(), Nested(), - Inner(), + Inner(), CONST, Companion.CONST, Nested.CONST, Interface.CONST, - a, - b() + a, + b() ) class Nested { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt deleted file mode 100644 index 03809337f68..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -open class Base(p: Any?) { - fun foo1(t: T) {} -} - -class D: Base("") { - inner class B : Base { - constructor() : super(foo1("")) - constructor(x: Int) : super(foo1(1)) - } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.kt index 02f3768a13d..90dad768ba1 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class Base(p: Any?) { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt deleted file mode 100644 index 7b41f938372..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -open class Base(p: Any?) { - fun foo1(t: T) {} -} - -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)) - } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.kt index 280bd7ae1f7..f6075711ae3 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class Base(p: Any?) { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt deleted file mode 100644 index b8f664c4a7f..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -open class Base(p: Any?) { - fun foo1() {} -} - -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()) - } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.kt index dfe314fde26..4eb9b91a4b8 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class Base(p: Any?) { fun foo1() {} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt deleted file mode 100644 index 47c8050aec7..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -open class Base(p: Any?) { - fun foo1(t: T) {} -} - -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("")) - } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.kt index d9b64e85b79..635e50eb4a1 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessGenericBaseWithSameExtension.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class Base(p: Any?) { fun foo1(t: T) {} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt index 4a0377caebc..0587532350d 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt @@ -6,6 +6,6 @@ class Outer { } constructor(x: Int) - constructor(x: Int, y: Int, z: Int = x + Inner().prop + this.Inner().prop) : - this(x + Inner().prop + this.Inner().prop) + constructor(x: Int, y: Int, z: Int = x + Inner().prop + this.Inner().prop) : + this(x + Inner().prop + this.Inner().prop) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/lambdaAsArgument.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/lambdaAsArgument.fir.kt index b9218464f5b..070ab01786a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/lambdaAsArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/lambdaAsArgument.fir.kt @@ -7,9 +7,9 @@ class A { constructor(x: () -> Int) constructor() : this( { - foo() + + foo() + this.foo() + this@A.foo() + - foobar() + foobar() }) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt index 32e6f820d1c..4d4dba66b20 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt @@ -2,6 +2,6 @@ class A { fun foo() = 1 constructor(x: Int) - constructor(x: Int, y: Int, z: Int = x + foo() + this.foo()) : - this(x + foo() + this.foo()) + constructor(x: Int, y: Int, z: Int = x + foo() + this.foo()) : + this(x + foo() + this.foo()) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt index d3bd8cf44b1..98f44bab93e 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsArgument.fir.kt @@ -6,7 +6,7 @@ class A { fun foo() = 1 constructor(x: Any?) constructor() : this(object { - fun bar() = foo() + this@A.foo() + - foobar() + super@A.hashCode() + fun bar() = foo() + this@A.foo() + + foobar() + super@A.hashCode() }) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsDefaultValueParameter.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsDefaultValueParameter.fir.kt index cca89cd5fc2..aae347dc766 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsDefaultValueParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/objectLiteralAsDefaultValueParameter.fir.kt @@ -5,7 +5,7 @@ fun A.foobar() = 3 class A { fun foo() = 1 constructor( x: Any = object { - fun bar() = foo() + this@A.foo() + - foobar() + fun bar() = foo() + this@A.foo() + + foobar() }) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt deleted file mode 100644 index d708b8faa7e..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -open class C(val x: Int) - -class D : C { - constructor() : super( - { - val s = "" - s() - ""() - 42 - }()) - - operator fun String.invoke() { } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.kt index 2e41e0ac12f..9eea603d151 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class C(val x: Int) class D : C { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt index 90ab3adca7f..3fadbf668ff 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt @@ -2,6 +2,6 @@ class A { val prop = 1 constructor(x: Int) - constructor(x: Int, y: Int, z: Int = x + prop + this.prop) : - this(x + prop + this.prop) + constructor(x: Int, y: Int, z: Int = x + prop + this.prop) : + this(x + prop + this.prop) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt index d67992b080f..e2ca27780a9 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt @@ -2,6 +2,6 @@ open class B(x: Int) class A : B { val prop = 1 - constructor(x: Int, y: Int = x + prop + this.prop) : - super(x + prop + this.prop) + constructor(x: Int, y: Int = x + prop + this.prop) : + super(x + prop + this.prop) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt index 6da0ba5e407..1031447dae2 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt @@ -3,6 +3,6 @@ open class B(x: Int) { fun foo() = 1 } class A : B { - constructor(x: Int, y: Int = x + foo() + this.foo() + super.foo()) : - super(x + foo() + this.foo() + super.foo()) + constructor(x: Int, y: Int = x + foo() + this.foo() + super.foo()) : + super(x + foo() + this.foo() + super.foo()) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt index 899a4e42928..43e6380b81a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt @@ -4,6 +4,6 @@ open class B(x: Int) { } class A : B { override fun foo() = 2 - constructor(x: Int, y: Int = x + foo() + this.foo() + super.foo()) : - super(x + foo() + this.foo() + super.foo()) + constructor(x: Int, y: Int = x + foo() + this.foo() + super.foo()) : + super(x + foo() + this.foo() + super.foo()) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt index ef877e454d8..dbfc4346104 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER open class B(val prop: Int) class A : B { - constructor(x: Int, y: Int = x + prop + this.prop + super.prop) : - super(x + prop + this.prop + super.prop) + constructor(x: Int, y: Int = x + prop + this.prop + super.prop) : + super(x + prop + this.prop + super.prop) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.fir.kt deleted file mode 100644 index 631933bf3db..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -fun A.foobar() = 1 -val A.prop: Int get() = 2 - -class A { - constructor(x: Int) - constructor() : this( - foobar() + - this.foobar() + - prop + - this.prop + - this@A.prop - ) -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.kt index 1a8a7a8b58f..6d2d1bb52a3 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun A.foobar() = 1 diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 0e6a951f598..f6e546c8458 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -849,6 +849,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/rawCastToStarProjection_Ok.kt"); } + @Test + @TestMetadata("receiverResolutionInDelegatedConstructor.kt") + public void testReceiverResolutionInDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/receiverResolutionInDelegatedConstructor.kt"); + } + @Test @TestMetadata("RecursiveResolve.kt") public void testRecursiveResolve() throws Exception {