From 652fd7ee7348acb243f4f7f587d7290372877de5 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 28 Aug 2019 16:29:29 +0300 Subject: [PATCH] FIR: fix dispatch receivers for objects --- .../kotlin/fir/resolve/calls/CallResolver.kt | 9 ++++----- .../kotlin/fir/resolve/calls/TowerLevels.kt | 15 ++++++++------- .../testData/resolve/expresssions/companion.txt | 2 +- .../resolve/expresssions/companionExtension.txt | 2 +- .../resolve/expresssions/importedReceiver.txt | 10 +++++----- .../testData/resolve/expresssions/outerObject.txt | 4 ++-- .../testData/resolve/fromBuilder/enums.txt | 2 +- .../resolve/multifile/importFromObject.txt | 2 +- .../irText/classes/objectWithInitializers.fir.txt | 2 ++ .../provideDelegate/memberExtension.fir.txt | 4 ++-- .../ir/irText/expressions/destructuring1.fir.txt | 4 ++-- .../destructuringWithUnderscore.fir.txt | 6 +++--- .../expressions/funImportedFromObject.fir.txt | 1 + .../expressions/membersImportedFromObject.fir.txt | 6 ++++-- .../ir/irText/expressions/objectReference.fir.txt | 14 ++++++++++++++ .../objectReferenceInFieldInitializer.fir.txt | 1 + .../irText/expressions/useImportedMember.fir.txt | 15 +++++++++++---- .../ir/irText/singletons/companion.fir.txt | 1 + .../testData/ir/irText/singletons/object.fir.txt | 1 + 19 files changed, 65 insertions(+), 36 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt index 32a4f3f5bad..0da4387e3a0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt @@ -169,6 +169,10 @@ class CallResolver( // Member of implicit receiver' type *and* relevant scope for (implicitReceiverValue in implicitReceiverValues) { + if (!blockDispatchReceivers || implicitReceiverValue !is ImplicitDispatchReceiverValue) { + // Direct use of implicit receiver (see inside) + group = processImplicitReceiver(towerDataConsumer, implicitReceiverValue, group) + } val implicitScope = implicitReceiverValue.implicitScope if (implicitScope != null) { // Regular implicit receiver scope (outer objects only?) @@ -188,15 +192,10 @@ class CallResolver( // } towerDataConsumer.consume(TowerDataKind.TOWER_LEVEL, ScopeTowerLevel(session, implicitCompanionScope), group++) } - if (blockDispatchReceivers) { - continue - } if (!implicitReceiverValue.boundSymbol.fir.isInner) { blockDispatchReceivers = true } } - // Direct use of implicit receiver (see inside) - group = processImplicitReceiver(towerDataConsumer, implicitReceiverValue, group) } // Member of top-level scope & importing scope 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 8d6edf28149..bf08fb50faf 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 @@ -153,7 +153,11 @@ class ScopeTowerLevel( val implicitExtensionReceiver: ImplicitReceiverValue<*>? = null ) : SessionBasedTowerLevel(session) { private fun FirCallableSymbol<*>.hasConsistentReceivers(extensionReceiver: ReceiverValue?): Boolean = - hasConsistentExtensionReceiver(extensionReceiver) && (scope is FirAbstractImportingScope || dispatchReceiverValue() == null) + when { + !hasConsistentExtensionReceiver(extensionReceiver) -> false + scope is FirAbstractImportingScope -> true + else -> dispatchReceiverValue().let { it == null || it.klassSymbol.fir.classKind == ClassKind.OBJECT } + } override fun > processElementsByName( token: TowerScopeLevel.Token, @@ -171,7 +175,7 @@ class ScopeTowerLevel( if (candidate.hasConsistentReceivers(extensionReceiver)) { val dispatchReceiverValue = when (candidate) { is FirBackingFieldSymbol -> candidate.fir.symbol.dispatchReceiverValue() - else -> null + else -> candidate.dispatchReceiverValue() } processor.consumeCandidate( candidate as T, dispatchReceiverValue = dispatchReceiverValue, @@ -184,7 +188,7 @@ class ScopeTowerLevel( TowerScopeLevel.Token.Functions -> scope.processFunctionsByName(name) { candidate -> if (candidate.hasConsistentReceivers(extensionReceiver)) { processor.consumeCandidate( - candidate as T, dispatchReceiverValue = null, + candidate as T, dispatchReceiverValue = candidate.dispatchReceiverValue(), implicitExtensionReceiverValue = implicitExtensionReceiver ) } else { @@ -241,15 +245,12 @@ class QualifiedReceiverTowerLevel(session: FirSession) : SessionBasedTowerLevel( } fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? { - // TODO: this is not true at least for inner class constructors + // TODO: this is not true atCall least for inner class constructors if (this is FirConstructor) return null val id = (this.symbol as ConeCallableSymbol).callableId.classId ?: return null val symbol = session.service().getClassLikeSymbolByFqName(id) as? FirClassSymbol ?: return null val regularClass = symbol.fir - // TODO: this is also not true, but objects can be also imported, companions can be also used implicitly - if (regularClass.classKind == ClassKind.OBJECT) return null - return ClassDispatchReceiverValue(regularClass.symbol) } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt index 29c6bdd1cf4..3a63510655d 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt @@ -18,7 +18,7 @@ FILE: companion.kt } public final fun bar(): R|kotlin/Unit| { - R|/A.Companion.foo|() + D|this@R|/A.Companion||.R|/A.Companion.foo|() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/companionExtension.txt b/compiler/fir/resolve/testData/resolve/expresssions/companionExtension.txt index a1f9d055c09..29ce9f03769 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/companionExtension.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/companionExtension.txt @@ -15,7 +15,7 @@ FILE: companionExtension.kt } public final fun test(): R|kotlin/Unit| { - E|this@R|/My||.R|/My.Companion.foo|() + D|this@R|/My.Companion||E|this@R|/My||.R|/My.Companion.foo|() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt b/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt index 8bdc5b94c9b..596bc9828c5 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/importedReceiver.txt @@ -26,10 +26,10 @@ FILE: importedReceiver.kt public final fun test(): R|kotlin/Unit| { E|Int(42)|.R|/foo|() E|String()|.R|/foo|() - E|Int(42)|.R|/My.bar|() - E|String()|.R|/My.bar|() - R|/My.baz|() - E|Boolean(true)|.R|/My.gau|() - R|FakeOverride|() + D|this@R|/My||E|Int(42)|.R|/My.bar|() + D|this@R|/My||E|String()|.R|/My.bar|() + D|this@R|/My||.R|/My.baz|() + D|this@R|/My||E|Boolean(true)|.R|/My.gau|() + D|this@R|/Your||.R|FakeOverride|() Boolean(false).#() } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/outerObject.txt b/compiler/fir/resolve/testData/resolve/expresssions/outerObject.txt index 97dec03c556..8a07462c128 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/outerObject.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/outerObject.txt @@ -15,11 +15,11 @@ FILE: outerObject.kt super() } - public final val y: R|kotlin/Int| = R|/Outer.x| + public final val y: R|kotlin/Int| = D|this@R|/Outer||.R|/Outer.x| public get(): R|kotlin/Int| public final fun test(): R|kotlin/Unit| { - E|this@R|/Outer.Nested||.R|/Outer.foo|() + D|this@R|/Outer||E|this@R|/Outer.Nested||.R|/Outer.foo|() } } diff --git a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt index ed219cb8708..284887f2cea 100644 --- a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt +++ b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt @@ -70,7 +70,7 @@ FILE: enums.kt } - public final val g: R|kotlin/Double| = D|D|R|/Planet.Companion.G||.R|kotlin/Double.times|(R|/m|)|.R|kotlin/Double.div|(D|R|/r||.R|kotlin/Double.times|(R|/r|)) + public final val g: R|kotlin/Double| = D|D|D|this@R|/Planet.Companion||.R|/Planet.Companion.G||.R|kotlin/Double.times|(R|/m|)|.R|kotlin/Double.div|(D|R|/r||.R|kotlin/Double.times|(R|/r|)) public get(): R|kotlin/Double| public abstract fun sayHello(): R|kotlin/Unit| diff --git a/compiler/fir/resolve/testData/resolve/multifile/importFromObject.txt b/compiler/fir/resolve/testData/resolve/multifile/importFromObject.txt index ab5be877796..cbc342b16aa 100644 --- a/compiler/fir/resolve/testData/resolve/multifile/importFromObject.txt +++ b/compiler/fir/resolve/testData/resolve/multifile/importFromObject.txt @@ -1,4 +1,4 @@ FILE: importFromObject.kt public final fun bar(): R|kotlin/Unit| { - R|a/A.foo|() + D|this@R|a/A||.R|a/A.foo|() } diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt b/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt index 2109fc8a362..098a45dbe60 100644 --- a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt +++ b/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt @@ -47,7 +47,9 @@ FILE fqName: fileName:/objectWithInitializers.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:public [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Test declared in .Test' type=.Test origin=null value: CALL 'public final fun (): kotlin.Int declared in .Test' type=kotlin.Int origin=null + $this: GET_VAR ': .Test declared in .Test' type=.Test origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt index 93eeb8cde87..0a8f2c5905f 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -59,7 +59,7 @@ FILE fqName: fileName:/memberExtension.kt FIELD DELEGATE name:plusK$delegate type:.Host.StringDelegate visibility:private [final] EXPRESSION_BODY CALL 'public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): .Host.StringDelegate declared in .Host' type=.Host.StringDelegate origin=null - $this: CONST String type=kotlin.String value="K" + $this: GET_VAR ': .Host declared in .Host' type=.Host origin=null host: GET_VAR ': .Host declared in .Host' type=.Host origin=null p: PROPERTY_REFERENCE 'public final plusK: IrErrorType [delegated,val]' field=null getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType @@ -74,7 +74,7 @@ FILE fqName: fileName:/memberExtension.kt FIELD PROPERTY_BACKING_FIELD name:ok type:IrErrorType visibility:public [final] EXPRESSION_BODY CALL 'public final fun (): IrErrorType declared in .Host' type=IrErrorType origin=null - $this: CONST String type=kotlin.String value="O" + $this: GET_VAR ': .Host declared in .Host' type=.Host origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType correspondingProperty: PROPERTY name:ok visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host diff --git a/compiler/testData/ir/irText/expressions/destructuring1.fir.txt b/compiler/testData/ir/irText/expressions/destructuring1.fir.txt index c02ccb3cd6e..203c48213e8 100644 --- a/compiler/testData/ir/irText/expressions/destructuring1.fir.txt +++ b/compiler/testData/ir/irText/expressions/destructuring1.fir.txt @@ -56,7 +56,7 @@ FILE fqName: fileName:/destructuring1.kt GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .B' type=kotlin.Int origin=null - $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null + $this: GET_VAR ': .B declared in .B' type=.B origin=null VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int declared in .B' type=kotlin.Int origin=null - $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null + $this: GET_VAR ': .B declared in .B' type=.B origin=null diff --git a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt index 00360657b01..b6d9a02a18b 100644 --- a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt +++ b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt @@ -62,10 +62,10 @@ FILE fqName: fileName:/destructuringWithUnderscore.kt GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .B' type=kotlin.Int origin=null - $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null + $this: GET_VAR ': .B declared in .B' type=.B origin=null VAR name:_ type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int declared in .B' type=kotlin.Int origin=null - $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null + $this: GET_VAR ': .B declared in .B' type=.B origin=null VAR name:z type:kotlin.Int [val] CALL 'public final fun component3 (): kotlin.Int declared in .B' type=kotlin.Int origin=null - $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null + $this: GET_VAR ': .B declared in .B' type=.B origin=null diff --git a/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt index 02870fa7d78..88ed77f8614 100644 --- a/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt @@ -29,3 +29,4 @@ FILE fqName:test fileName:/funImportedFromObject.kt RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in test' CALL 'public final fun foo (): kotlin.String [inline] declared in test.Host' type=kotlin.String origin=null : + $this: GET_VAR ': test.Host declared in test.Host' type=test.Host origin=null diff --git a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt index 85e02a4b0c9..07fec87445f 100644 --- a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt @@ -51,6 +51,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY CALL 'public final fun foo (): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: GET_VAR ': .A declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -60,6 +61,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: GET_VAR ': .A declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -69,7 +71,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY CALL 'public final fun fooExt (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: CONST Int type=kotlin.Int value=1 + $this: GET_VAR ': .A declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY @@ -79,7 +81,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: CONST Int type=kotlin.Int value=1 + $this: GET_VAR ': .A declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/objectReference.fir.txt b/compiler/testData/ir/irText/expressions/objectReference.fir.txt index 9fe4f187de2..0c650bffd4b 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.txt @@ -31,8 +31,10 @@ FILE fqName: fileName:/objectReference.kt $this: VALUE_PARAMETER name: type:.Z BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -47,8 +49,10 @@ FILE fqName: fileName:/objectReference.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -58,8 +62,10 @@ FILE fqName: fileName:/objectReference.kt $this: VALUE_PARAMETER name: type:.Z.Nested BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -86,8 +92,10 @@ FILE fqName: fileName:/objectReference.kt $this: VALUE_PARAMETER name: type:.Z BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -113,8 +121,10 @@ FILE fqName: fileName:/objectReference.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -124,8 +134,10 @@ FILE fqName: fileName:/objectReference.kt $this: VALUE_PARAMETER name: type:.Z.anObject. BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 @@ -156,8 +168,10 @@ FILE fqName: fileName:/objectReference.kt $receiver: VALUE_PARAMETER name: type:.Z BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z value: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.fir.txt b/compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.fir.txt index 71f4eda1e0d..833f8110149 100644 --- a/compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.fir.txt @@ -22,6 +22,7 @@ FILE fqName: fileName:/objectReferenceInFieldInitializer.kt STRING_CONCATENATION type=kotlin.String CONST String type=kotlin.String value="1234" CALL 'private final fun (): kotlin.String declared in .A' type=kotlin.String origin=null + $this: GET_VAR ': .A declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.A) returnType:kotlin.String correspondingProperty: PROPERTY name:b visibility:private modality:FINAL [val] $this: VALUE_PARAMETER name: type:.A diff --git a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt index 6b93d896063..66d5683af6c 100644 --- a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt @@ -148,6 +148,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun f (s: kotlin.Int): kotlin.Int declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C' type=.C origin=null s: CONST Int type=kotlin.Int value=1 arg1: CONST Int type=kotlin.Int value=1 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -157,6 +158,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun f (s: kotlin.String): kotlin.Int declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C' type=.C origin=null s: CONST String type=kotlin.String value="s" arg1: CONST Int type=kotlin.Int value=2 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -166,7 +168,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun f (): kotlin.Int declared in .C' type=kotlin.Int origin=null - $this: CONST Boolean type=kotlin.Boolean value=true + $this: GET_VAR ': .C declared in .C' type=.C origin=null arg1: CONST Int type=kotlin.Int value=3 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="3" @@ -175,16 +177,19 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C' type=.C origin=null arg1: CONST Int type=kotlin.Int value=4 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="4" SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:public' type=kotlin.Unit origin=null + receiver: GET_VAR ': .C declared in .C' type=.C origin=null value: CONST Int type=kotlin.Int value=5 WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C' type=.C origin=null arg1: CONST Int type=kotlin.Int value=5 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="5" @@ -193,7 +198,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=null - $this: CONST Int type=kotlin.Int value=5 + $this: GET_VAR ': .C declared in .C' type=.C origin=null arg1: CONST Int type=kotlin.Int value=6 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="6" @@ -203,6 +208,7 @@ FILE fqName: fileName:/useImportedMember.kt $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun g1 (t: T of .C.g1): T of .C.g1 declared in .C' type=kotlin.String origin=null : + $this: GET_VAR ': .C declared in .C' type=.C origin=null t: CONST String type=kotlin.String value="7" arg1: CONST String type=kotlin.String value="7" then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -212,7 +218,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun (): T of declared in .C' type=kotlin.String origin=null - $this: CONST String type=kotlin.String value="8" + $this: GET_VAR ': .C declared in .C' type=.C origin=null arg1: CONST String type=kotlin.String value="8" then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="8" @@ -229,7 +235,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public final fun (): T of declared in .BaseClass' type=kotlin.String origin=null - $this: CONST String type=kotlin.String value="10" + $this: GET_VAR ': .BaseClass declared in .BaseClass' type=.BaseClass origin=null arg1: CONST String type=kotlin.String value="10" then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="10" @@ -238,6 +244,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'public open fun genericFromSuper (g: kotlin.String): kotlin.String declared in .I' type=kotlin.String origin=null + $this: GET_VAR ': .I declared in .I' type=.I<*> origin=null g: CONST String type=kotlin.String value="11" arg1: CONST String type=kotlin.String value="11" then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' diff --git a/compiler/testData/ir/irText/singletons/companion.fir.txt b/compiler/testData/ir/irText/singletons/companion.fir.txt index 5e9f127f813..c83cf7ff5dd 100644 --- a/compiler/testData/ir/irText/singletons/companion.fir.txt +++ b/compiler/testData/ir/irText/singletons/companion.fir.txt @@ -9,6 +9,7 @@ FILE fqName: fileName:/companion.kt $this: VALUE_PARAMETER name: type:.Z BLOCK_BODY CALL 'public final fun test (): kotlin.Unit declared in .Z.Companion' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z.Companion declared in .Z.Companion' type=.Z.Companion origin=null CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z.Companion CONSTRUCTOR visibility:private <> () returnType:.Z.Companion [primary] diff --git a/compiler/testData/ir/irText/singletons/object.fir.txt b/compiler/testData/ir/irText/singletons/object.fir.txt index c63edc83044..cb5df1efd66 100644 --- a/compiler/testData/ir/irText/singletons/object.fir.txt +++ b/compiler/testData/ir/irText/singletons/object.fir.txt @@ -18,6 +18,7 @@ FILE fqName: fileName:/object.kt $this: VALUE_PARAMETER name: type:.Z.A BLOCK_BODY CALL 'public final fun test (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null + $this: GET_VAR ': .Z declared in .Z' type=.Z origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any