diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt index de986b1acdf..8d6edf28149 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt @@ -144,7 +144,7 @@ class MemberScopeTowerLevel( // We can access here members of currently accessible scope which is not influenced by explicit receiver // We can either have no explicit receiver at all, or it can be an extension receiver // An explicit receiver never can be a dispatch receiver at this level -// So: dispatch receiver = strictly none (EXCEPTION: importing scopes with import from objects) +// So: dispatch receiver = strictly none (EXCEPTIONS: importing scopes with import from objects, synthetic field variable) // So: extension receiver = either none or explicit // (if explicit receiver exists, it always *should* be an extension receiver) class ScopeTowerLevel( @@ -169,8 +169,12 @@ class ScopeTowerLevel( return when (token) { TowerScopeLevel.Token.Properties -> scope.processPropertiesByName(name) { candidate -> if (candidate.hasConsistentReceivers(extensionReceiver)) { + val dispatchReceiverValue = when (candidate) { + is FirBackingFieldSymbol -> candidate.fir.symbol.dispatchReceiverValue() + else -> null + } processor.consumeCandidate( - candidate as T, dispatchReceiverValue = null, + candidate as T, dispatchReceiverValue = dispatchReceiverValue, implicitExtensionReceiverValue = implicitExtensionReceiver ) } else { diff --git a/compiler/fir/resolve/testData/resolve/localObject.txt b/compiler/fir/resolve/testData/resolve/localObject.txt index 0a40de8ad7a..70892f47516 100644 --- a/compiler/fir/resolve/testData/resolve/localObject.txt +++ b/compiler/fir/resolve/testData/resolve/localObject.txt @@ -45,7 +45,7 @@ FILE: localObject.kt } - F|/TestProperty.x| = R|/value| + D|this@R|/TestProperty||.F|/TestProperty.x| = R|/value| } public final val y: R|kotlin/Int| diff --git a/compiler/testData/ir/irText/classes/initVar.fir.txt b/compiler/testData/ir/irText/classes/initVar.fir.txt index ba415b73fa1..01fe14e5b02 100644 --- a/compiler/testData/ir/irText/classes/initVar.fir.txt +++ b/compiler/testData/ir/irText/classes/initVar.fir.txt @@ -102,6 +102,7 @@ FILE fqName: fileName:/initVar.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarInInitBlock declared in .TestInitVarInInitBlock' type=.TestInitVarInInitBlock origin=null value: CONST Int type=kotlin.Int value=0 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: @@ -139,6 +140,7 @@ FILE fqName: fileName:/initVar.kt VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarWithCustomSetter declared in .TestInitVarWithCustomSetter' type=.TestInitVarWithCustomSetter origin=null value: GET_VAR 'value: kotlin.Int declared in .TestInitVarWithCustomSetter.' type=kotlin.Int origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: @@ -170,10 +172,12 @@ FILE fqName: fileName:/initVar.kt VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarWithCustomSetterWithExplicitCtor declared in .TestInitVarWithCustomSetterWithExplicitCtor' type=.TestInitVarWithCustomSetterWithExplicitCtor origin=null value: GET_VAR 'value: kotlin.Int declared in .TestInitVarWithCustomSetterWithExplicitCtor.' type=kotlin.Int origin=null ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarWithCustomSetterWithExplicitCtor declared in .TestInitVarWithCustomSetterWithExplicitCtor' type=.TestInitVarWithCustomSetterWithExplicitCtor origin=null value: CONST Int type=kotlin.Int value=0 CONSTRUCTOR visibility:public <> () returnType:.TestInitVarWithCustomSetterWithExplicitCtor BLOCK_BODY @@ -209,10 +213,12 @@ FILE fqName: fileName:/initVar.kt VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarWithCustomSetterInCtor declared in .TestInitVarWithCustomSetterInCtor' type=.TestInitVarWithCustomSetterInCtor origin=null value: GET_VAR 'value: kotlin.Int declared in .TestInitVarWithCustomSetterInCtor.' type=kotlin.Int origin=null CONSTRUCTOR visibility:public <> () returnType:.TestInitVarWithCustomSetterInCtor BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .TestInitVarWithCustomSetterInCtor declared in .TestInitVarWithCustomSetterInCtor' type=.TestInitVarWithCustomSetterInCtor origin=null value: CONST Int type=kotlin.Int value=42 DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitVarWithCustomSetterInCtor modality:FINAL visibility:public superTypes:[kotlin.Any]'