[K/N] Fix references for inline function

Corresponding lowering creating wrappers from JS Backend was used.

Also, the lowering was changed to create local function, instead of
normal one in outer scope, as a lot of logic from local declarations
lowering should be duplicated otherwise for correct type parameters
handling.

^KT-38535
This commit is contained in:
Pavel Kunyavskiy
2022-08-02 16:00:47 +02:00
committed by Space
parent 2f75ea585e
commit 5034581788
19 changed files with 235 additions and 42 deletions
@@ -2,7 +2,6 @@ package org.jetbrains.kotlin.backend.konan
import org.jetbrains.kotlin.backend.common.*
import org.jetbrains.kotlin.backend.common.lower.*
import org.jetbrains.kotlin.backend.common.lower.StringConcatenationLowering
import org.jetbrains.kotlin.backend.common.lower.inline.FunctionInlining
import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesExtractionFromInlineFunctionsLowering
import org.jetbrains.kotlin.backend.common.lower.inline.LocalClassesInInlineFunctionsLowering
@@ -160,6 +159,12 @@ internal val extractLocalClassesFromInlineBodies = makeKonanFileOpPhase(
prerequisite = setOf(sharedVariablesPhase), // TODO: add "soft" dependency on inventNamesForLocalClasses
)
internal val wrapInlineDeclarationsWithReifiedTypeParametersLowering = makeKonanFileLoweringPhase(
::WrapInlineDeclarationsWithReifiedTypeParametersLowering,
name = "WrapInlineDeclarationsWithReifiedTypeParameters",
description = "Wrap inline declarations with reified type parameters"
)
internal val inlinePhase = makeKonanFileOpPhase(
{ context, irFile ->
irFile.acceptChildrenVoid(object : IrElementVisitorVoid {
@@ -252,6 +252,7 @@ internal val allLoweringsPhase = NamedCompilerPhase(
sharedVariablesPhase,
inventNamesForLocalClasses,
extractLocalClassesFromInlineBodies,
wrapInlineDeclarationsWithReifiedTypeParametersLowering,
inlinePhase,
provisionalFunctionExpressionPhase,
postInlinePhase,
@@ -74,6 +74,8 @@ internal class NativeInlineFunctionResolver(override val context: Context) : Def
LocalClassesExtractionFromInlineFunctionsLowering(context).lower(body, notLoweredFunction)
}
WrapInlineDeclarationsWithReifiedTypeParametersLowering(context).lower(body, notLoweredFunction)
return notLoweredFunction
}