diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt index 7896c1b0802..35e8b27e7fc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ImplicitReceiverStack.kt @@ -68,8 +68,14 @@ class ImplicitReceiverStackImpl private constructor( } override operator fun get(name: String?): ImplicitReceiverValue<*>? { - if (name == null) return stack.lastOrNull() - return indexesPerLabel[Name.identifier(name)].lastOrNull()?.let { stack[it] } + if (name == null) { + return stack.lastOrNull { + it !is ImplicitDispatchReceiverValue || !it.inDelegated + } + } + return indexesPerLabel[Name.identifier(name)].lastOrNull()?.let { stack[it] }?.takeIf { + it !is ImplicitDispatchReceiverValue || !it.inDelegated + } } override fun lastDispatchReceiver(): ImplicitDispatchReceiverValue? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index 94d853bded4..41db8ba6252 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -84,8 +84,8 @@ internal class ExpressionReceiverValue( sealed class ImplicitReceiverValue>( val boundSymbol: S, type: ConeKotlinType, - private val useSiteSession: FirSession, - private val scopeSession: ScopeSession + protected val useSiteSession: FirSession, + protected val scopeSession: ScopeSession ) : ReceiverValue { final override var type: ConeKotlinType = type private set @@ -120,6 +120,7 @@ sealed class ImplicitReceiverValue>( internal enum class ImplicitDispatchReceiverKind { REGULAR, + REGULAR_IN_DELEGATED, COMPANION, COMPANION_FROM_SUPERTYPE } @@ -138,6 +139,11 @@ class ImplicitDispatchReceiverValue internal constructor( useSiteSession, scopeSession, kind ) + fun copyForDelegated(): ImplicitDispatchReceiverValue = + ImplicitDispatchReceiverValue(boundSymbol, type, useSiteSession, scopeSession, ImplicitDispatchReceiverKind.REGULAR_IN_DELEGATED) + + val inDelegated: Boolean get() = kind == ImplicitDispatchReceiverKind.REGULAR_IN_DELEGATED + val implicitCompanion: Boolean get() = kind != ImplicitDispatchReceiverKind.REGULAR val companionFromSupertype: Boolean get() = kind == ImplicitDispatchReceiverKind.COMPANION_FROM_SUPERTYPE diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index bcf9bbbfcdd..47f10603f69 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -60,7 +60,7 @@ class FirTowerResolver( if (!it.implicitCompanion && klass?.isCompanion == true) { explicitCompanions += klass.symbol } - if (firstDispatchValue) { + if (firstDispatchValue && !it.inDelegated) { if (!it.implicitCompanion && klass?.isInner == false && !symbol.classId.isLocal @@ -69,7 +69,7 @@ class FirTowerResolver( } true } else { - symbol.fir.classKind == ClassKind.OBJECT + symbol.fir.classKind == ClassKind.OBJECT && !it.inDelegated } } } 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 7ae24ba419d..085d65c9f99 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 @@ -594,13 +594,23 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : var callCompleted = true var result = delegatedConstructorCall try { + val lastDispatchReceiver = implicitReceiverStack.lastDispatchReceiver() + val name = lastDispatchReceiver?.boundSymbol?.classId?.shortClassName + if (lastDispatchReceiver != null) { + context.implicitReceiverStack.pop(name) + context.implicitReceiverStack.add(name, lastDispatchReceiver.copyForDelegated()) + } delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent) + if (lastDispatchReceiver != null) { + context.implicitReceiverStack.pop(name) + context.implicitReceiverStack.add(name, lastDispatchReceiver) + } val typeArguments: List val symbol: FirClassSymbol<*> = when (val reference = delegatedConstructorCall.calleeReference) { is FirThisReference -> { typeArguments = emptyList() if (reference.boundSymbol == null) { - implicitReceiverStack.lastDispatchReceiver()?.boundSymbol?.also { + lastDispatchReceiver?.boundSymbol?.also { reference.replaceBoundSymbol(it) } ?: return delegatedConstructorCall.compose() } else { @@ -611,15 +621,15 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : // TODO: unresolved supertype val supertype = reference.superTypeRef.coneTypeSafe() ?: return delegatedConstructorCall.compose() val expandedSupertype = supertype.fullyExpandedType(session) - val symbol = - expandedSupertype.lookupTag.toSymbol(session) as? FirClassSymbol<*> ?: return delegatedConstructorCall.compose() + val symbol = + expandedSupertype.lookupTag.toSymbol(session) as? FirClassSymbol<*> ?: return delegatedConstructorCall.compose() val classTypeParametersCount = (symbol.fir as? FirTypeParametersOwner)?.typeParameters?.size ?: 0 - typeArguments = expandedSupertype.typeArguments - .takeLast(classTypeParametersCount) // Hack for KT-37525 - .takeIf { it.isNotEmpty() } - ?.map { it.toFirTypeProjection() } - ?: emptyList() - symbol + typeArguments = expandedSupertype.typeArguments + .takeLast(classTypeParametersCount) // Hack for KT-37525 + .takeIf { it.isNotEmpty() } + ?.map { it.toFirTypeProjection() } + ?: emptyList() + symbol } else -> return delegatedConstructorCall.compose() } diff --git a/compiler/testData/codegen/box/classes/selfcreate.kt b/compiler/testData/codegen/box/classes/selfcreate.kt index 2c6f1571e17..95d67471511 100644 --- a/compiler/testData/codegen/box/classes/selfcreate.kt +++ b/compiler/testData/codegen/box/classes/selfcreate.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class B () {} open class A(val b : B) { diff --git a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda.kt index 3ca7fdae198..42833d259ec 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda.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/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda2.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda2.kt index 00b8b5124f3..4b135115783 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda2.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedInInlineLambda2.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/closures/captureInSuperConstructorCall/properValueCapturedByClosure2.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/properValueCapturedByClosure2.kt index 6229a09625f..5416746471e 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/properValueCapturedByClosure2.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/properValueCapturedByClosure2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class Outer(val fn: (() -> String)?) { companion object { val ok = "OK" diff --git a/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt b/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt index f54ae5829ac..74124f89a58 100644 --- a/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt +++ b/compiler/testData/codegen/box/localClasses/anonymousObjectInExtension.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun WithCompanion.test(): String { object : WithCompanion(this) {} return "OK" diff --git a/compiler/testData/codegen/box/objects/selfReferenceToObjectInInlineLambdaInSuperConstructorCall.kt b/compiler/testData/codegen/box/objects/selfReferenceToObjectInInlineLambdaInSuperConstructorCall.kt index 23a07287ebf..045499084e6 100644 --- a/compiler/testData/codegen/box/objects/selfReferenceToObjectInInlineLambdaInSuperConstructorCall.kt +++ b/compiler/testData/codegen/box/objects/selfReferenceToObjectInInlineLambdaInSuperConstructorCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR abstract class Base(val fn: () -> String) object Test : Base(run { { Test.ok() } }) { diff --git a/compiler/testData/codegen/box/objects/thisRefToObjectInNestedClassConstructorCall.kt b/compiler/testData/codegen/box/objects/thisRefToObjectInNestedClassConstructorCall.kt index 1ce188eb889..2b9f1ebb049 100644 --- a/compiler/testData/codegen/box/objects/thisRefToObjectInNestedClassConstructorCall.kt +++ b/compiler/testData/codegen/box/objects/thisRefToObjectInNestedClassConstructorCall.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - open class Base(val s: String) object Host { diff --git a/compiler/testData/diagnostics/tests/regressions/noThis.fir.kt b/compiler/testData/diagnostics/tests/regressions/noThis.fir.kt index 71aa9ab8f50..8530a32e330 100644 --- a/compiler/testData/diagnostics/tests/regressions/noThis.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/noThis.fir.kt @@ -6,5 +6,5 @@ class B : A { override fun f() {} class C : A by this {} class D(val x : B = this) - class E : P(this) + class E : P(this) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt index 886c5b062cf..b0b1ba41a3b 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/constructors.fir.kt @@ -37,8 +37,8 @@ class A( Companion.CONST, Nested.CONST, Interface.CONST, - a, - b() + a, + b() ) class Nested { diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.fir.kt deleted file mode 100644 index f08b997802d..00000000000 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -open class S(val a: Any, val b: Any, val c: Any) {} - -object A : S(prop1, prop2, func()) { - val prop1 = 1 - val prop2: Int - get() = 1 - fun func() {} -} diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.kt index 4304fc3db6f..75189a1a868 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/objectSuperConstructorArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class S(val a: Any, val b: Any, val c: Any) {} object A : S(prop1, prop2, func()) { diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArguments.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArguments.fir.kt index 4a54b354afe..df93189da0a 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArguments.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArguments.fir.kt @@ -20,8 +20,8 @@ class A : S ( Companion.CONST, Nested.CONST, Interface.CONST, - a, - b() + a, + b() ) { class Nested { diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt index c20c5465d08..d8af76026be 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/superConstructorArgumentsInSecondaryConstructor.fir.kt @@ -22,8 +22,8 @@ class A : S { Companion.CONST, Nested.CONST, Interface.CONST, - a, - b() + a, + b() ) class Nested { diff --git a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.fir.kt b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.fir.kt index 9dc7be2c959..0b64ce516e5 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.fir.kt @@ -5,7 +5,7 @@ import java.util.HashMap //KT-250 Incorrect variable resolve in constructor arguments of superclass open class A(val x: Int) -class B(y: Int) : A(x) //x is resolved as a property in a, so no error is generated +class B(y: Int) : A(x) //x is resolved as a property in a, so no error is generated //KT-617 Prohibit dollars in call to superclass constructors open class M(p: Int) @@ -29,9 +29,9 @@ abstract class TagWithText(name : String) : Tag(name) { open class BodyTag(name : String) : TagWithText(name) { } -class Body() : BodyTag(name) { // Must be an error! +class Body() : BodyTag(name) { // Must be an error! } -class Body1() : BodyTag(this.name) { // Must be an error! +class Body1() : BodyTag(this.name) { // Must be an error! } //more tests @@ -40,10 +40,10 @@ open class X(p: Int, r: Int) { val s = "s" } -class Y(i: Int) : X(i, rrr) { +class Y(i: Int) : X(i, rrr) { val rrr = 3 } -class Z(val i: Int) : X(s, x) { +class Z(val i: Int) : X(s, x) { val x = 2 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase.fir.kt index 2153e3f94e1..4460d545f43 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() : 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 f16da07a325..f80d80725cf 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseGenericFromInnerExtendingSameBase2.fir.kt @@ -7,7 +7,7 @@ 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) : 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 ba8a1560feb..74f089f42d4 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/accessBaseWithSameExtension.fir.kt @@ -7,6 +7,6 @@ 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(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 d0f53ae4f08..b77e3cd6f82 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() : 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(x: Int, y: Int, z: Int) : super(this@B.foo1("")) } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt index 76c24c1b31d..8752e827de7 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/innerInstanceCreation.fir.kt @@ -7,5 +7,5 @@ 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) + 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 1a01acc6fb0..5d7ae9d4aff 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() + - this.foo() + - this@A.foo() + - foobar() + foo() + + this.foo() + + this@A.foo() + + foobar() }) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt index f67d2a5ec49..9768c7fc02b 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/memberFunAccess.fir.kt @@ -3,5 +3,5 @@ class A { fun foo() = 1 constructor(x: Int) constructor(x: Int, y: Int, z: Int = x + foo() + this.foo()) : - this(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 dd0522dc156..b5c5e646f71 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/operatorCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt index 4fe0347386c..0065247b64e 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt @@ -4,8 +4,8 @@ class D : C { constructor() : super( { val s = "" - s() - ""() + s() + ""() 42 }()) diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt index 73c5b28e651..0a85c195b37 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccess.fir.kt @@ -3,5 +3,5 @@ class A { val prop = 1 constructor(x: Int) constructor(x: Int, y: Int, z: Int = x + prop + this.prop) : - this(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 d6b566fc562..54ad148dc47 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/propertyAccessUnitialized.fir.kt @@ -3,5 +3,5 @@ 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) + 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 ba91b894ba4..9b66f0d54a6 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccess.fir.kt @@ -4,5 +4,5 @@ open class B(x: Int) { } class A : B { constructor(x: Int, y: Int = x + foo() + this.foo() + super.foo()) : - super(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 3e7a6494ba1..adb40bd6f57 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superFunAccessOverriden.fir.kt @@ -5,5 +5,5 @@ 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()) + 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 9c5d9ee7b9c..4d07dbcfcd7 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/superPropertyAccess.fir.kt @@ -2,5 +2,5 @@ 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) + 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 index 67d31be0d8a..4b99f10c2bc 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/thisAsExtensionReceiver.fir.kt @@ -5,10 +5,10 @@ val A.prop: Int get() = 2 class A { constructor(x: Int) - constructor() : this( - foobar() + + constructor() : this( + foobar() + this.foobar() + - prop + + prop + this.prop + this@A.prop ) diff --git a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt index e90717063a2..770791f121a 100644 --- a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt @@ -41,7 +41,7 @@ FILE fqName: fileName:/thisRefToObjectInNestedClassConstructorCall.kt CONSTRUCTOR visibility:public <> () returnType:.Host.Derived1 [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Any) [primary] declared in .Base' - x: GET_VAR ': .Host.Derived1 declared in .Host.Derived1' type=.Host.Derived1 origin=null + x: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base]' PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Host.Derived1) returnType:kotlin.Any [fake_override] diff --git a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt index 14b6e001b64..371d4728827 100644 --- a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt @@ -8,7 +8,8 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.test. CONSTRUCTOR visibility:private <> () returnType:.test. [primary] BLOCK_BODY - ERROR_CALL 'Cannot find delegated constructor call' type=.WithCompanion + DELEGATING_CONSTRUCTOR_CALL 'public constructor (a: .WithCompanion.Companion) [primary] declared in .WithCompanion' + a: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=.WithCompanion.Companion INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.WithCompanion]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL VAR name:test2 type:.test. [val] @@ -18,7 +19,8 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt CONSTRUCTOR visibility:private <> () returnType:.test. [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (a: .WithCompanion.Companion) [primary] declared in .WithCompanion' - a: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + a: CALL 'public final fun foo (): .WithCompanion.Companion declared in .WithCompanion.Companion' type=.WithCompanion.Companion origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=.WithCompanion.Companion INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.WithCompanion]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL CLASS CLASS name:WithCompanion modality:OPEN visibility:public superTypes:[kotlin.Any]