Change usages of IrFunctionImpl to more common IrSimpleFunction

This commit is contained in:
Ivan Kylchik
2020-03-23 13:56:55 +03:00
parent c45993b2b1
commit 28d6752315
@@ -278,7 +278,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
} }
"hashCode" -> { "hashCode" -> {
if (irFunction.parentAsClass.isEnumClass) { if (irFunction.parentAsClass.isEnumClass) {
calculateBuiltIns(irFunction.getLastOverridden() as IrFunctionImpl, data) calculateBuiltIns(irFunction.getLastOverridden() as IrSimpleFunction, data)
} else { } else {
throw AssertionError("Hash code function intrinsic is supported only for enum class") throw AssertionError("Hash code function intrinsic is supported only for enum class")
} }
@@ -305,12 +305,12 @@ class IrInterpreter(irModule: IrModuleFragment) {
return irFunction.body!!.interpret(data) return irFunction.body!!.interpret(data)
} }
private suspend fun calculateOverridden(owner: IrFunctionImpl, data: Frame): Code { private suspend fun calculateOverridden(owner: IrSimpleFunction, data: Frame): Code {
val variableDescriptor = owner.symbol.getReceiver()!! val variableDescriptor = owner.symbol.getReceiver()!!
val superQualifier = (data.getVariableState(variableDescriptor) as? Complex)?.superType val superQualifier = (data.getVariableState(variableDescriptor) as? Complex)?.superType
if (superQualifier == null) { if (superQualifier == null) {
// superQualifier is null for exception state => find method in builtins // superQualifier is null for exception state => find method in builtins
return calculateBuiltIns(owner.getLastOverridden() as IrFunctionImpl, data) return calculateBuiltIns(owner.getLastOverridden() as IrSimpleFunction, data)
} }
val overridden = owner.overriddenSymbols.first { it.getReceiver()?.equalTo(superQualifier.getReceiver()) == true } val overridden = owner.overriddenSymbols.first { it.getReceiver()?.equalTo(superQualifier.getReceiver()) == true }
@@ -319,7 +319,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
.map { Variable(it.second.descriptor, data.getVariableState(it.first.descriptor)) } .map { Variable(it.second.descriptor, data.getVariableState(it.first.descriptor)) }
.forEach { newStates.addVar(it) } .forEach { newStates.addVar(it) }
val overriddenOwner = overridden.owner as IrFunctionImpl val overriddenOwner = overridden.owner
return when { return when {
overriddenOwner.body != null -> overriddenOwner.interpret(newStates) overriddenOwner.body != null -> overriddenOwner.interpret(newStates)
superQualifier.superType == null -> calculateBuiltIns(overriddenOwner, newStates) superQualifier.superType == null -> calculateBuiltIns(overriddenOwner, newStates)
@@ -329,7 +329,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
private suspend fun calculateBuiltIns(irFunction: IrFunction, data: Frame): Code { private suspend fun calculateBuiltIns(irFunction: IrFunction, data: Frame): Code {
val descriptor = irFunction.descriptor val descriptor = irFunction.descriptor
val methodName = when (val property = (irFunction as? IrFunctionImpl)?.correspondingPropertySymbol) { val methodName = when (val property = (irFunction as? IrSimpleFunction)?.correspondingPropertySymbol) {
null -> descriptor.name.asString() null -> descriptor.name.asString()
else -> property.owner.name.asString() else -> property.owner.name.asString()
} }
@@ -432,7 +432,7 @@ class IrInterpreter(irModule: IrModuleFragment) {
isWrapper && !isInterfaceDefaultMethod -> (dispatchReceiver as Wrapper).getMethod(irFunction).invokeMethod(irFunction, newFrame) isWrapper && !isInterfaceDefaultMethod -> (dispatchReceiver as Wrapper).getMethod(irFunction).invokeMethod(irFunction, newFrame)
irFunction.hasAnnotation(evaluateIntrinsicAnnotation) -> Wrapper.getStaticMethod(irFunction).invokeMethod(irFunction, newFrame) irFunction.hasAnnotation(evaluateIntrinsicAnnotation) -> Wrapper.getStaticMethod(irFunction).invokeMethod(irFunction, newFrame)
irFunction.isAbstract() -> calculateAbstract(irFunction, newFrame) //abstract check must be before fake overridden check irFunction.isAbstract() -> calculateAbstract(irFunction, newFrame) //abstract check must be before fake overridden check
irFunction.isFakeOverridden() -> calculateOverridden(irFunction as IrFunctionImpl, newFrame) irFunction.isFakeOverridden() -> calculateOverridden(irFunction as IrSimpleFunction, newFrame)
irFunction.body == null || dispatchReceiver is Primitive<*> -> calculateBuiltIns(irFunction, newFrame) irFunction.body == null || dispatchReceiver is Primitive<*> -> calculateBuiltIns(irFunction, newFrame)
else -> irFunction.interpret(newFrame) else -> irFunction.interpret(newFrame)
} }