Remove unnecessary getThisAsReceiver function from Utils.kt file

This commit is contained in:
Ivan Kylchik
2020-05-29 15:21:08 +03:00
parent c6240face0
commit 99d823da8a
2 changed files with 2 additions and 6 deletions
@@ -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
@@ -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
}