From 99d823da8ac64af93af9ace86eff7c1921463040 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Fri, 29 May 2020 15:21:08 +0300 Subject: [PATCH] Remove unnecessary getThisAsReceiver function from Utils.kt file --- .../kotlin/backend/common/interpreter/IrInterpreter.kt | 2 +- .../jetbrains/kotlin/backend/common/interpreter/Utils.kt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt index 29c33093ff2..78bf8bf00ee 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/IrInterpreter.kt @@ -366,7 +366,7 @@ class IrInterpreter(irModule: IrModuleFragment, private val declarationsMap: Map constructorCall.dispatchReceiver!!.interpret().check { return it } state.outerClass = Variable(constructorCall.symbol.owner.dispatchReceiverParameter!!.descriptor, stack.popReturnValue()) } - valueArguments.add(Variable(constructorCall.getThisAsReceiver(), state)) //used to set up fields in body + valueArguments.add(Variable(irClass.thisReceiver!!.descriptor, state)) //used to set up fields in body return stack.newFrame(initPool = valueArguments + state.typeArguments) { val statements = constructorCall.getBody()!!.statements // enum entry use IrTypeOperatorCall with IMPLICIT_COERCION_TO_UNIT as delegation call, but we need the value diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Utils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Utils.kt index 9f7a29070f5..dc2e3fc813d 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Utils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/interpreter/Utils.kt @@ -24,11 +24,6 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver import org.jetbrains.kotlin.utils.addToStdlib.safeAs -// main purpose is to get receiver from constructor call -fun IrMemberAccessExpression.getThisAsReceiver(): DeclarationDescriptor { - return (this.symbol.descriptor.containingDeclaration as ClassDescriptor).thisAsReceiverParameter -} - fun IrFunction.getDispatchReceiver(): DeclarationDescriptor? { return (this.symbol.descriptor.containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter } @@ -51,6 +46,7 @@ fun DeclarationDescriptor.equalTo(other: DeclarationDescriptor): Boolean { private fun WrappedReceiverParameterDescriptor.isEqualTo(other: DeclarationDescriptor): Boolean { return when (val container = this.containingDeclaration) { + is ClassDescriptor -> container == other.containingDeclaration is FunctionDescriptor -> container.dispatchReceiverParameter == other || container.extensionReceiverParameter == other else -> false }