Refactor extensions for plugin intrinsics entry points

so platform-specific parts won't have unsafe downcasts.
This commit is contained in:
Leonid Startsev
2022-08-29 18:45:49 +02:00
committed by Space
parent eae588abea
commit 763303fe97
7 changed files with 80 additions and 54 deletions
@@ -34,6 +34,8 @@ class PsiInlineIntrinsicsSupport(
private val reportErrorsOn: KtElement,
private val typeSystem: TypeSystemCommonBackendContext
) : ReifiedTypeInliner.IntrinsicsSupport<KotlinType> {
private val pluginExtensions = ExpressionCodegenExtension.getInstances(state.project)
override fun putClassInstance(v: InstructionAdapter, type: KotlinType) {
DescriptorAsmUtil.putJavaLangClassInstance(v, state.typeMapper.mapType(type), type, state.typeMapper)
}
@@ -90,9 +92,15 @@ class PsiInlineIntrinsicsSupport(
instructions: InsnList,
type: KotlinType,
asmType: Type
): Int {
return ExpressionCodegenExtension.getInstances(state.project)
.map { it.applyPluginDefinedReifiedOperationMarker(insn, instructions, type, asmType, state.typeMapper, typeSystem, state.module) }
.maxOrNull() ?: -1
}
): Int = pluginExtensions.maxOfOrNull {
it.applyPluginDefinedReifiedOperationMarker(
insn,
instructions,
type,
asmType,
state.typeMapper,
typeSystem,
state.module
)
} ?: -1
}