IR: refactor resolveFakeOverride call sites

Split it to 4 functions for clarity: resolveFakeOverride,
resolveFakeOverrideOrFail, resolveFakeOverrideMaybeAbstract,
resolveFakeOverrideMaybeAbstractOrFail. Remove/inline duplicated
utilities and remove unused parameters.
This commit is contained in:
Alexander Udalov
2023-08-23 15:37:01 +02:00
committed by Space Team
parent e52529a1d1
commit b5ba9ee671
19 changed files with 72 additions and 80 deletions
@@ -307,7 +307,7 @@ internal fun KotlinStubs.generateObjCCall(
receiver: ObjCCallReceiver,
arguments: List<IrExpression?>
) = builder.irBlock {
val resolved = method.resolveFakeOverride(allowAbstract = true)?: method
val resolved = method.resolveFakeOverrideMaybeAbstract() ?: method
val isDirect = directSymbolName != null
val exceptionMode = ForeignExceptionMode.byValue(
@@ -306,7 +306,7 @@ internal object VirtualTablesLookup {
}
internal fun IrSimpleFunction.findOverriddenMethodOfAny() =
resolveFakeOverride(allowAbstract = false).takeIf { it?.parentClassOrNull?.isAny() == true }
resolveFakeOverride().takeIf { it?.parentClassOrNull?.isAny() == true }
/*
* Special trampoline function to call actual virtual implementation. This helps with reducing
@@ -1533,7 +1533,7 @@ private fun ObjCExportCodeGenerator.itablePlace(irFunction: IrSimpleFunction): C
assert(irFunction.isOverridable)
val irClass = irFunction.parentAsClass
return if (irClass.isInterface
&& (irFunction.isReal || irFunction.resolveFakeOverride(allowAbstract = true)?.parent != context.irBuiltIns.anyClass.owner)
&& (irFunction.isReal || irFunction.resolveFakeOverrideMaybeAbstract()?.parent != context.irBuiltIns.anyClass.owner)
) {
context.getLayoutBuilder(irClass).itablePlace(irFunction)
} else {
@@ -1088,7 +1088,7 @@ private class InteropTransformer(
builder.at(expression)
val function = expression.symbol.owner
if ((function as? IrSimpleFunction)?.resolveFakeOverride(allowAbstract = true)?.symbol
if ((function as? IrSimpleFunction)?.resolveFakeOverrideMaybeAbstract()?.symbol
== symbols.interopNativePointedRawPtrGetter) {
// Replace by the intrinsic call to be handled by code generator: