From a93c7a39e0d251296530862039bb37a47bcd74ed Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 8 Apr 2020 16:09:21 +0300 Subject: [PATCH] [FIR] Provide object [dispatch] && callable reference receivers properly --- .../resolve/expresssions/importedReceiver.txt | 10 +- .../resolve/multifile/importFromObject.txt | 2 +- .../generators/CallAndReferenceGenerator.kt | 20 ---- .../kotlin/fir/resolve/calls/Candidate.kt | 10 +- .../fir/resolve/calls/tower/TowerLevels.kt | 54 ++++++++--- ...rCallCompletionResultsWriterTransformer.kt | 4 +- ...rCapturedAsImplicitThisInBoundReference.kt | 1 - ...7257_boundReferenceWithImplicitReceiver.kt | 2 - .../box/jvm8/defaults/callableReference.kt | 1 - ...ssToExtensionPropertyImportedFromObject.kt | 1 - ...ntToExtensionPropertyImportedFromObject.kt | 1 - .../isInitializedAndDeinitialize/emptyLhs.kt | 1 - .../nonInlineLambda.kt | 1 - .../provideDelegate/memberExtension.fir.txt | 4 - .../withArgumentAdaptationAndReceiver.fir.txt | 1 + .../membersImportedFromObject.fir.txt | 92 ------------------- .../expressions/membersImportedFromObject.kt | 1 + .../expressions/useImportedMember.fir.txt | 8 +- 18 files changed, 62 insertions(+), 152 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/importedReceiver.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/importedReceiver.txt index 608f6632ade..a62fdc9dd54 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/importedReceiver.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/importedReceiver.txt @@ -26,10 +26,10 @@ FILE: importedReceiver.kt public final fun test(): R|kotlin/Unit| { Int(42).R|/foo|() String().R|/foo|() - Int(42).R|/My.bar|() - String().R|/My.bar|() - R|/My.baz|() - Boolean(true).R|/My.gau|() + (Q|My|, Int(42)).R|/My.bar|() + (Q|My|, String()).R|/My.bar|() + Q|My|.R|/My.baz|() + (Q|My|, Boolean(true)).R|/My.gau|() R|/Your.wat|() - Boolean(false).R|FakeOverride|() + (Q|My|, Boolean(false)).R|FakeOverride|() } diff --git a/compiler/fir/analysis-tests/testData/resolve/multifile/importFromObject.txt b/compiler/fir/analysis-tests/testData/resolve/multifile/importFromObject.txt index 19ae59180c4..272fa212f1a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/multifile/importFromObject.txt +++ b/compiler/fir/analysis-tests/testData/resolve/multifile/importFromObject.txt @@ -10,5 +10,5 @@ FILE: a.kt } FILE: b.kt public final fun bar(): R|kotlin/Unit| { - R|a/A.foo|() + Q|a/A|.R|a/A.foo|() } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 6a50cbb25a6..702cd1576de 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -5,12 +5,8 @@ package org.jetbrains.kotlin.fir.backend.generators -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.backend.* -import org.jetbrains.kotlin.fir.backend.convertWithOffsets -import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.psi @@ -19,7 +15,6 @@ import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.render -import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol @@ -37,7 +32,6 @@ import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classifierOrNull import org.jetbrains.kotlin.ir.types.makeNotNull -import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.psi.KtPropertyDelegate internal class CallAndReferenceGenerator( @@ -373,20 +367,6 @@ internal class CallAndReferenceGenerator( } visitor.convertToIrExpression(it) } - ?: run { - // Object case - val callableReference = calleeReference as? FirResolvedNamedReference - val ownerClassId = (callableReference?.resolvedSymbol as? FirCallableSymbol<*>)?.callableId?.classId - val ownerClassSymbol = - ownerClassId?.takeUnless { it.isLocal }?.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 = classifierStorage.getCachedIrClass(firClass)!! - IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol) - } - } ?: run { if (this is FirCallableReferenceAccess) return null val name = if (isDispatch) "Dispatch" else "Extension" diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt index f4e4358165a..71c5506583f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.FirArgumentList import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList +import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS @@ -116,13 +117,16 @@ class Candidate( val diagnostics: MutableList = mutableListOf() fun dispatchReceiverExpression(): FirExpression = when (explicitReceiverKind) { - ExplicitReceiverKind.DISPATCH_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> callInfo.explicitReceiver!! + ExplicitReceiverKind.DISPATCH_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> + callInfo.explicitReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression else -> dispatchReceiverValue?.receiverExpression ?: FirNoReceiverExpression } fun extensionReceiverExpression(): FirExpression = when (explicitReceiverKind) { - ExplicitReceiverKind.EXTENSION_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> callInfo.explicitReceiver!! - else -> implicitExtensionReceiverValue?.receiverExpression ?: FirNoReceiverExpression + ExplicitReceiverKind.EXTENSION_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> + callInfo.explicitReceiver?.takeIf { it !is FirExpressionStub } ?: FirNoReceiverExpression + else -> + implicitExtensionReceiverValue?.receiverExpression ?: FirNoReceiverExpression } override fun equals(other: Any?): Boolean { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt index ee4bdcdde6e..72da46b23f1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerLevels.kt @@ -5,18 +5,24 @@ package org.jetbrains.kotlin.fir.resolve.calls.tower +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.isInner import org.jetbrains.kotlin.fir.declarations.isStatic import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.* +import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType +import org.jetbrains.kotlin.fir.resolve.typeForQualifier import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractImportingScope +import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.classId @@ -183,6 +189,37 @@ class ScopeTowerLevel( else -> true } + private fun dispatchReceiverValue(scope: FirScope, candidate: FirCallableSymbol<*>): ReceiverValue? { + val holderId = candidate.callableId.classId + if (holderId != null && scope is FirExplicitSimpleImportingScope) { + val symbol = session.firSymbolProvider.getClassLikeSymbolByFqName(holderId) + if (symbol is FirRegularClassSymbol && + symbol.fir.classKind.let { it == ClassKind.OBJECT || it == ClassKind.ENUM_ENTRY } + ) { + val resolvedQualifier = buildResolvedQualifier { + packageFqName = holderId.packageFqName + relativeClassFqName = holderId.relativeClassName + safe = false + this.symbol = symbol + }.apply { + resultType = bodyResolveComponents.typeForQualifier(this) + } + return ExpressionReceiverValue(resolvedQualifier) + } + } + return when { + candidate !is FirBackingFieldSymbol -> null + candidate.callableId.classId != null -> { + bodyResolveComponents.implicitReceiverStack.lastDispatchReceiver { implicitReceiverValue -> + implicitReceiverValue.type.classId == holderId + } + } + else -> { + bodyResolveComponents.implicitReceiverStack.lastDispatchReceiver() + } + } + } + override fun > processElementsByName( token: TowerScopeLevel.Token, name: Name, @@ -194,19 +231,7 @@ class ScopeTowerLevel( TowerScopeLevel.Token.Properties -> scope.processPropertiesByName(name) { candidate -> empty = false if (candidate.hasConsistentReceivers(extensionReceiver)) { - val dispatchReceiverValue = - when { - candidate !is FirBackingFieldSymbol -> null - candidate.callableId.classId != null -> { - val propertyHolderId = candidate.callableId.classId - bodyResolveComponents.implicitReceiverStack.lastDispatchReceiver { implicitReceiverValue -> - implicitReceiverValue.type.classId == propertyHolderId - } - } - else -> { - bodyResolveComponents.implicitReceiverStack.lastDispatchReceiver() - } - } + val dispatchReceiverValue = dispatchReceiverValue(scope, candidate) processor.consumeCandidate( candidate as T, dispatchReceiverValue, implicitExtensionReceiverValue = extensionReceiver as? ImplicitReceiverValue<*> @@ -221,8 +246,9 @@ class ScopeTowerLevel( ) { candidate -> empty = false if (candidate.hasConsistentReceivers(extensionReceiver)) { + val dispatchReceiverValue = dispatchReceiverValue(scope, candidate) processor.consumeCandidate( - candidate as T, dispatchReceiverValue = null, + candidate as T, dispatchReceiverValue, implicitExtensionReceiverValue = extensionReceiver as? ImplicitReceiverValue<*> ) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 63d3cf8e7f9..cd90094a09b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -126,7 +126,9 @@ class FirCallCompletionResultsWriterTransformer( resolvedSymbol = calleeReference.candidateSymbol inferredTypeArguments.addAll(computeTypeArgumentTypes(calleeReference.candidate)) }, - ).compose() + ).transformDispatchReceiver(StoreReceiver, subCandidate.dispatchReceiverExpression()) + .transformExtensionReceiver(StoreReceiver, subCandidate.extensionReceiverExpression()) + .compose() } override fun transformVariableAssignment( diff --git a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedAsImplicitThisInBoundReference.kt b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedAsImplicitThisInBoundReference.kt index d16ef253b0d..cf797c460ad 100644 --- a/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedAsImplicitThisInBoundReference.kt +++ b/compiler/testData/codegen/box/closures/captureInSuperConstructorCall/outerCapturedAsImplicitThisInBoundReference.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR abstract class Base(val fn: () -> String) class Outer { diff --git a/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt b/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt index c225cfcb620..50948f805ff 100644 --- a/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt +++ b/compiler/testData/codegen/box/enum/kt7257_boundReferenceWithImplicitReceiver.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - enum class X { B { override val value = "OK" diff --git a/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt b/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt index 0dbccb3ff18..9ccd6cc7e97 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/callableReference.kt @@ -1,5 +1,4 @@ // !JVM_DEFAULT_MODE: enable -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToExtensionPropertyImportedFromObject.kt b/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToExtensionPropertyImportedFromObject.kt index d79a41e9742..358a1b9ddfd 100644 --- a/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToExtensionPropertyImportedFromObject.kt +++ b/compiler/testData/codegen/box/objects/compoundAssignmentToArrayAccessToExtensionPropertyImportedFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import Host.x diff --git a/compiler/testData/codegen/box/objects/compoundAssignmentToExtensionPropertyImportedFromObject.kt b/compiler/testData/codegen/box/objects/compoundAssignmentToExtensionPropertyImportedFromObject.kt index cb1d9e4f19b..593c7d6242f 100644 --- a/compiler/testData/codegen/box/objects/compoundAssignmentToExtensionPropertyImportedFromObject.kt +++ b/compiler/testData/codegen/box/objects/compoundAssignmentToExtensionPropertyImportedFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import Host.x object A { diff --git a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/emptyLhs.kt b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/emptyLhs.kt index 1169945b3a3..4e5c78fdc56 100644 --- a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/emptyLhs.kt +++ b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/emptyLhs.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME package test diff --git a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/nonInlineLambda.kt b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/nonInlineLambda.kt index fb510e827f8..7081da4455f 100644 --- a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/nonInlineLambda.kt +++ b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/nonInlineLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME class Foo { diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt index 9a42b93b2c5..d317677272b 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -63,8 +63,6 @@ FILE fqName: fileName:/memberExtension.kt $receiver: CONST String type=kotlin.String value="K" host: GET_VAR ': .Host declared in .Host' type=.Host origin=null p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty2.Host, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE - $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host, $receiver:kotlin.String) returnType:kotlin.String correspondingProperty: PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.Host @@ -76,8 +74,6 @@ FILE fqName: fileName:/memberExtension.kt receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty2.Host, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE - $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host PROPERTY name:ok visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ok type:kotlin.String visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt index 1c5e892a6ba..6d745578ef1 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt @@ -22,6 +22,7 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType FUNCTION_REFERENCE 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + $this: GET_VAR ': .Host declared in .Host.testImplicitThis' type=.Host origin=null FUN name:testBoundReceiverLocalVal visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt deleted file mode 100644 index 7d882ef8409..00000000000 --- a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt +++ /dev/null @@ -1,92 +0,0 @@ -FILE fqName: fileName:/membersImportedFromObject.kt - CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:private <> () returnType:.A [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Int declared in .A' - CONST Int type=kotlin.Int value=1 - FUN name:fooExt visibility:public modality:FINAL <> ($this:.A, $receiver:kotlin.Int) returnType:kotlin.Int - $this: VALUE_PARAMETER name: type:.A - $receiver: VALUE_PARAMETER name: type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun fooExt (): kotlin.Int declared in .A' - CONST Int type=kotlin.Int value=2 - PROPERTY name:bar visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=42 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int - correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - PROPERTY name:barExt visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.A, $receiver:kotlin.Int) returnType:kotlin.Int - correspondingProperty: PROPERTY name:barExt visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - $receiver: VALUE_PARAMETER name: type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' - CONST Int type=kotlin.Int value=43 - 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 - PROPERTY name:test1 visibility:public modality:FINAL [val] - 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_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 - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null - PROPERTY name:test2 visibility:public modality:FINAL [val] - 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=GET_PROPERTY - $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 - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null - PROPERTY name:test3 visibility:public modality:FINAL [val] - 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: CONST Int type=kotlin.Int value=1 - $receiver: 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 - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null - PROPERTY name:test4 visibility:public modality:FINAL [val] - 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=GET_PROPERTY - $this: CONST Int type=kotlin.Int value=1 - $receiver: 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 - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:private [final,static]' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/membersImportedFromObject.kt b/compiler/testData/ir/irText/expressions/membersImportedFromObject.kt index 8b1ba910953..40429706853 100644 --- a/compiler/testData/ir/irText/expressions/membersImportedFromObject.kt +++ b/compiler/testData/ir/irText/expressions/membersImportedFromObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import A.foo import A.bar import A.fooExt diff --git a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt index d18b559757a..fbb6d84825a 100644 --- a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt @@ -180,7 +180,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean [operator] 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_OBJECT 'CLASS OBJECT name:C modality:FINAL visibility:public superTypes:[.BaseClass; .I]' type=.C $receiver: CONST Boolean type=kotlin.Boolean value=true arg1: CONST Int type=kotlin.Int value=3 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -211,7 +211,7 @@ FILE fqName: fileName:/useImportedMember.kt if: CALL 'public final fun not (): kotlin.Boolean [operator] 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=GET_PROPERTY - $this: CONST Int type=kotlin.Int value=5 + $this: GET_OBJECT 'CLASS OBJECT name:C modality:FINAL visibility:public superTypes:[.BaseClass; .I]' type=.C $receiver: CONST Int type=kotlin.Int value=5 arg1: CONST Int type=kotlin.Int value=6 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -233,7 +233,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 (): T of .C. declared in .C' type=kotlin.String origin=GET_PROPERTY : kotlin.String - $this: CONST String type=kotlin.String value="8" + $this: GET_OBJECT 'CLASS OBJECT name:C modality:FINAL visibility:public superTypes:[.BaseClass; .I]' type=.C $receiver: CONST String type=kotlin.String value="8" arg1: CONST String type=kotlin.String value="8" then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' @@ -244,7 +244,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 open fun fromInterface (): T of .C.fromInterface [fake_override] declared in .C' type=kotlin.Int origin=null : kotlin.Int - $this: CONST Int type=kotlin.Int value=9 + $this: GET_OBJECT 'CLASS OBJECT name:C modality:FINAL visibility:public superTypes:[.BaseClass; .I]' type=.C $receiver: CONST Int type=kotlin.Int value=9 arg1: CONST Int type=kotlin.Int value=9 then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in '