From 15f373a864823f171c283fedadcd76b294b71f15 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 27 Dec 2019 12:23:12 +0300 Subject: [PATCH] FIR2IR: support object receiver case (this fixes 24 black box tests) --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 40 ++++++++++++---- .../compatibility/privateCompanionObject.kt | 1 - ...accessPrivateInlineClassCompanionMethod.kt | 1 - ...ccessPrivateInlineClassCompanionMethod2.kt | 1 - ...PrivateStaticInlineClassCompanionMethod.kt | 1 - .../toPrivateCompanionFun.kt | 1 - .../toPrivateCompanionVal.kt | 1 - .../codegen/box/innerNested/kt6804.kt | 1 - .../jvmStatic/importStaticMemberFromObject.kt | 1 - .../codegen/box/jvmStatic/privateMethod.kt | 1 - .../box/jvmStatic/syntheticAccessor.kt | 1 - .../objects/companionObjectAccess/kt27121.kt | 1 - .../companionObjectAccess/kt27121_lv12.kt | 1 - .../companionObjectAccess/kt27121_lv13.kt | 1 - ...ateCompanionObjectAccessedFromInitBlock.kt | 1 - ...bjectAccessedFromInitBlockOfNestedClass.kt | 1 - ...eCompanionObjectAccessedFromNestedClass.kt | 1 - ...jectAccessedFromNestedClassSeveralTimes.kt | 1 - ...dCompanionObjectAccessedFromNestedClass.kt | 1 - ...dAssignmentToPropertyImportedFromObject.kt | 1 - .../testData/codegen/box/objects/kt1047.kt | 1 - .../testData/codegen/box/objects/kt2675.kt | 1 - ...DerivedClassCallsProtectedFromCompanion.kt | 1 - .../accessToCompanion.kt | 1 - .../codegen/box/statics/syntheticAccessor.kt | 1 - .../expressions/funImportedFromObject.fir.txt | 32 ------------- .../expressions/funImportedFromObject.kt | 1 + .../membersImportedFromObject.fir.txt | 8 ++-- .../expressions/objectReference.fir.txt | 10 ++-- .../ir/irText/singletons/companion.fir.txt | 47 ------------------- .../ir/irText/singletons/companion.kt | 1 + .../ir/irText/singletons/object.fir.txt | 47 ------------------- .../testData/ir/irText/singletons/object.kt | 1 + 33 files changed, 41 insertions(+), 170 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt delete mode 100644 compiler/testData/ir/irText/singletons/companion.fir.txt delete mode 100644 compiler/testData/ir/irText/singletons/object.fir.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 066203b50f9..221cb303be1 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -793,22 +793,42 @@ class Fir2IrVisitor( } } + private fun FirQualifiedAccess.findIrDispatchReceiver(): IrExpression = findIrReceiver(isDispatch = true) + + private fun FirQualifiedAccess.findIrExtensionReceiver(): IrExpression = findIrReceiver(isDispatch = false) + + private fun FirQualifiedAccess.findIrReceiver(isDispatch: Boolean): IrExpression { + val firReceiver = if (isDispatch) dispatchReceiver else extensionReceiver + return firReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression() + ?: explicitReceiver?.toIrExpression() // NB: this applies to the situation when call is unresolved + ?: run { + // Object case + val callableReference = calleeReference as? FirResolvedNamedReference + val ownerClassId = (callableReference?.resolvedSymbol as? FirCallableSymbol<*>)?.callableId?.classId + val ownerClassSymbol = ownerClassId?.let { session.firSymbolProvider.getClassLikeSymbolByFqName(it) } + val firClass = (ownerClassSymbol?.fir as? FirClass)?.takeIf { + it is FirAnonymousObject || it is FirRegularClass && it.classKind == ClassKind.OBJECT + } + firClass?.convertWithOffsets { startOffset, endOffset -> + val irClass = declarationStorage.getIrClass(firClass, setParent = false) + IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol) + } + } ?: run { + val name = if (isDispatch) "Dispatch" else "Extension" + throw AssertionError( + "$name receiver expected: ${render()} to ${calleeReference.render()}" + ) + } + } + private fun IrExpression.applyReceivers(qualifiedAccess: FirQualifiedAccess): IrExpression { return when (this) { is IrCallImpl -> { val ownerFunction = symbol.owner if (ownerFunction.dispatchReceiverParameter != null) { - dispatchReceiver = qualifiedAccess.dispatchReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression() - ?: qualifiedAccess.explicitReceiver?.toIrExpression() // NB: this applies to the situation when call is unresolved - if (dispatchReceiver == null) { - throw AssertionError() - } + dispatchReceiver = qualifiedAccess.findIrDispatchReceiver() } else if (ownerFunction.extensionReceiverParameter != null) { - extensionReceiver = qualifiedAccess.extensionReceiver.takeIf { it !is FirNoReceiverExpression }?.toIrExpression() - ?: qualifiedAccess.explicitReceiver?.toIrExpression() - if (extensionReceiver == null) { - throw AssertionError() - } + extensionReceiver = qualifiedAccess.findIrExtensionReceiver() } this } diff --git a/compiler/testData/codegen/box/compatibility/privateCompanionObject.kt b/compiler/testData/codegen/box/compatibility/privateCompanionObject.kt index 39fe5d36fb4..0e380040c7d 100644 --- a/compiler/testData/codegen/box/compatibility/privateCompanionObject.kt +++ b/compiler/testData/codegen/box/compatibility/privateCompanionObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Test { private companion object { val res = "OK" diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt index a51731a8946..c1350b46f34 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR inline class R(private val r: Int) { fun test() = ok() diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt index be023a05a05..80e66d49441 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateInlineClassCompanionMethod2.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR inline class R(private val r: Long) { fun test() = ok() diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt index 5d6093adccd..bfbe3334f9b 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/accessPrivateStaticInlineClassCompanionMethod.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionFun.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionFun.kt index 6281c83b450..259b032c86e 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionFun.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionFun.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR inline class R(private val r: Int) { fun test() = pf() diff --git a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionVal.kt b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionVal.kt index c7706c9eb0d..ef803e57da9 100644 --- a/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionVal.kt +++ b/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/toPrivateCompanionVal.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR inline class R(private val r: Int) { fun test() = pv diff --git a/compiler/testData/codegen/box/innerNested/kt6804.kt b/compiler/testData/codegen/box/innerNested/kt6804.kt index 0b43431da9c..edb201a622e 100644 --- a/compiler/testData/codegen/box/innerNested/kt6804.kt +++ b/compiler/testData/codegen/box/innerNested/kt6804.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { class Nested { fun fn() = s diff --git a/compiler/testData/codegen/box/jvmStatic/importStaticMemberFromObject.kt b/compiler/testData/codegen/box/jvmStatic/importStaticMemberFromObject.kt index e9186de6fbb..05643950b88 100644 --- a/compiler/testData/codegen/box/jvmStatic/importStaticMemberFromObject.kt +++ b/compiler/testData/codegen/box/jvmStatic/importStaticMemberFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/jvmStatic/privateMethod.kt b/compiler/testData/codegen/box/jvmStatic/privateMethod.kt index 148cc1bfc62..099b6ed01a7 100644 --- a/compiler/testData/codegen/box/jvmStatic/privateMethod.kt +++ b/compiler/testData/codegen/box/jvmStatic/privateMethod.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/jvmStatic/syntheticAccessor.kt b/compiler/testData/codegen/box/jvmStatic/syntheticAccessor.kt index 519be0f3f2c..ebc66fedb74 100644 --- a/compiler/testData/codegen/box/jvmStatic/syntheticAccessor.kt +++ b/compiler/testData/codegen/box/jvmStatic/syntheticAccessor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121.kt index e7b2455e73e..88ffe4fdfd6 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun test() = ok() diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv12.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv12.kt index eb085736ab8..cb4d99b5ff0 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv12.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv12.kt @@ -1,5 +1,4 @@ // !LANGUAGE: -ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun test() = ok() diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv13.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv13.kt index db8f933bdc9..36e79e7b819 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv13.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/kt27121_lv13.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun test() = ok() diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt index 6f0487fd310..3e013c26c52 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlock.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR class Outer { private companion object { diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt index f0eb08a3485..203625bdf85 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromInitBlockOfNestedClass.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR class Outer { private companion object { diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClass.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClass.kt index a9611be57d1..588f0dfcd54 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClass.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClass.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR class Outer { private companion object { diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClassSeveralTimes.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClassSeveralTimes.kt index 5d8a988521c..9f10e2ba1cb 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClassSeveralTimes.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/privateCompanionObjectAccessedFromNestedClassSeveralTimes.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR class Outer { private companion object { diff --git a/compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt b/compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt index 5d8666588ba..505151fbbbe 100644 --- a/compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt +++ b/compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField -// IGNORE_BACKEND_FIR: JVM_IR class Outer { protected companion object { diff --git a/compiler/testData/codegen/box/objects/compoundAssignmentToPropertyImportedFromObject.kt b/compiler/testData/codegen/box/objects/compoundAssignmentToPropertyImportedFromObject.kt index f4fe2394d65..db7d276732c 100644 --- a/compiler/testData/codegen/box/objects/compoundAssignmentToPropertyImportedFromObject.kt +++ b/compiler/testData/codegen/box/objects/compoundAssignmentToPropertyImportedFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import Host.x object Host { diff --git a/compiler/testData/codegen/box/objects/kt1047.kt b/compiler/testData/codegen/box/objects/kt1047.kt index 94a8fa9a6d5..3ca6e581e53 100644 --- a/compiler/testData/codegen/box/objects/kt1047.kt +++ b/compiler/testData/codegen/box/objects/kt1047.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE diff --git a/compiler/testData/codegen/box/objects/kt2675.kt b/compiler/testData/codegen/box/objects/kt2675.kt index 6dd4e70caf1..3cd63cc3262 100644 --- a/compiler/testData/codegen/box/objects/kt2675.kt +++ b/compiler/testData/codegen/box/objects/kt2675.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A() { fun ok() = Foo.Bar.bar() + Foo.Bar.barv diff --git a/compiler/testData/codegen/box/objects/nestedDerivedClassCallsProtectedFromCompanion.kt b/compiler/testData/codegen/box/objects/nestedDerivedClassCallsProtectedFromCompanion.kt index 796e63303db..a9a05baa90e 100644 --- a/compiler/testData/codegen/box/objects/nestedDerivedClassCallsProtectedFromCompanion.kt +++ b/compiler/testData/codegen/box/objects/nestedDerivedClassCallsProtectedFromCompanion.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { companion object { protected fun foo() = "OK" diff --git a/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt b/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt index 932d0565614..0c9e1d2df2e 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR internal class A(val result: Int) { companion object { fun foo(): Int = 1 diff --git a/compiler/testData/codegen/box/statics/syntheticAccessor.kt b/compiler/testData/codegen/box/statics/syntheticAccessor.kt index 92661416a8b..2a390400701 100644 --- a/compiler/testData/codegen/box/statics/syntheticAccessor.kt +++ b/compiler/testData/codegen/box/statics/syntheticAccessor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR object A { private val p = "OK"; diff --git a/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt deleted file mode 100644 index 8b277db3592..00000000000 --- a/compiler/testData/ir/irText/expressions/funImportedFromObject.fir.txt +++ /dev/null @@ -1,32 +0,0 @@ -FILE fqName:test fileName:/funImportedFromObject.kt - CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test.Host - CONSTRUCTOR visibility:private <> () returnType:test.Host [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:FINAL ($this:test.Host) returnType:kotlin.String [inline] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:test.Host - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String [inline] declared in test.Host' - CONST String type=kotlin.String value="OK" - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - 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 - : kotlin.Any - $this: GET_VAR ': test.Host declared in test.Host' type=test.Host origin=null diff --git a/compiler/testData/ir/irText/expressions/funImportedFromObject.kt b/compiler/testData/ir/irText/expressions/funImportedFromObject.kt index 8da3cd52f7f..759dbd03d86 100644 --- a/compiler/testData/ir/irText/expressions/funImportedFromObject.kt +++ b/compiler/testData/ir/irText/expressions/funImportedFromObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL package test import test.Host.foo diff --git a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt index 231c1be0767..e6db74c154b 100644 --- a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt @@ -51,7 +51,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Int visibility:private [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 + $this: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -61,7 +61,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:private [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 + $this: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -71,7 +71,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Int visibility:private [final,static] EXPRESSION_BODY CALL 'public final fun fooExt (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: GET_VAR ': .A declared in .A' type=.A origin=null + $this: CONST Int type=kotlin.Int value=1 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY @@ -81,7 +81,7 @@ FILE fqName: fileName:/membersImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:private [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 + $this: CONST Int type=kotlin.Int value=1 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 a1f04ebac70..f0935cc3e55 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.txt @@ -49,10 +49,9 @@ FILE fqName: fileName:/objectReference.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:private' 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 + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:private' 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 @@ -62,10 +61,9 @@ 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:private' 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 + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:private' 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 @@ -168,10 +166,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:private' type=kotlin.Unit origin=null - receiver: GET_VAR ': .Z declared in .Z' type=.Z origin=null + receiver: GET_VAR ': .Z declared in .test' 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 + $this: GET_VAR ': .Z declared in .test' type=.Z origin=null SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:private' 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/singletons/companion.fir.txt b/compiler/testData/ir/irText/singletons/companion.fir.txt deleted file mode 100644 index 8f3f8fdb5a9..00000000000 --- a/compiler/testData/ir/irText/singletons/companion.fir.txt +++ /dev/null @@ -1,47 +0,0 @@ -FILE fqName: fileName:/companion.kt - CLASS CLASS name:Z modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z - CONSTRUCTOR visibility:public <> () returnType:.Z [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:test2 visibility:public modality:FINAL <> ($this:.Z) returnType:kotlin.Unit - $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] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' - FUN name:test visibility:public modality:FINAL <> ($this:.Z.Companion) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Z.Companion - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/singletons/companion.kt b/compiler/testData/ir/irText/singletons/companion.kt index 40ddd570948..ce6af54dd4d 100644 --- a/compiler/testData/ir/irText/singletons/companion.kt +++ b/compiler/testData/ir/irText/singletons/companion.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Z { fun test2() { diff --git a/compiler/testData/ir/irText/singletons/object.fir.txt b/compiler/testData/ir/irText/singletons/object.fir.txt deleted file mode 100644 index 3721ba3be67..00000000000 --- a/compiler/testData/ir/irText/singletons/object.fir.txt +++ /dev/null @@ -1,47 +0,0 @@ -FILE fqName: fileName:/object.kt - CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z - CONSTRUCTOR visibility:private <> () returnType:.Z [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:test visibility:public modality:FINAL <> ($this:.Z) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Z - BLOCK_BODY - CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z.A - CONSTRUCTOR visibility:public <> () returnType:.Z.A [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:test2 visibility:public modality:FINAL <> ($this:.Z.A) returnType:kotlin.Unit - $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 [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/singletons/object.kt b/compiler/testData/ir/irText/singletons/object.kt index 299cee993d2..c9c04c45853 100644 --- a/compiler/testData/ir/irText/singletons/object.kt +++ b/compiler/testData/ir/irText/singletons/object.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL object Z { fun test() {}