[JS IR] Remove inline properties with reified parameters

RemoveInlineFunctionsWithReifiedTypeParametersLowering -> RemoveInlineDeclarationsWithReifiedTypeParametersLowering
This commit is contained in:
Zalim Bashorov
2020-12-08 16:51:47 +03:00
parent da8dacb495
commit c1f6a72ae1
3 changed files with 17 additions and 13 deletions
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering
import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering
import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLowering
import org.jetbrains.kotlin.ir.backend.js.lower.inline.CopyInlineFunctionBodyLowering
import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineFunctionsWithReifiedTypeParametersLowering
import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineDeclarationsWithReifiedTypeParametersLowering
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
@@ -234,8 +234,8 @@ private val copyInlineFunctionBodyLoweringPhase = makeDeclarationTransformerPhas
prerequisite = setOf(functionInliningPhase)
)
private val removeInlineFunctionsWithReifiedTypeParametersLoweringPhase = makeDeclarationTransformerPhase(
{ RemoveInlineFunctionsWithReifiedTypeParametersLowering() },
private val removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase = makeDeclarationTransformerPhase(
{ RemoveInlineDeclarationsWithReifiedTypeParametersLowering() },
name = "RemoveInlineFunctionsWithReifiedTypeParametersLowering",
description = "Remove Inline functions with reified parameters from context",
prerequisite = setOf(functionInliningPhase)
@@ -571,7 +571,7 @@ private val typeOperatorLoweringPhase = makeBodyLoweringPhase(
description = "Lower IrTypeOperator with corresponding logic",
prerequisite = setOf(
bridgesConstructionPhase,
removeInlineFunctionsWithReifiedTypeParametersLoweringPhase,
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase,
singleAbstractMethodPhase, errorExpressionLoweringPhase
)
)
@@ -704,7 +704,7 @@ val loweringList = listOf<Lowering>(
localClassesExtractionFromInlineFunctionsPhase,
functionInliningPhase,
copyInlineFunctionBodyLoweringPhase,
removeInlineFunctionsWithReifiedTypeParametersLoweringPhase,
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase,
createScriptFunctionsPhase,
callableReferenceLowering,
singleAbstractMethodPhase,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -9,15 +9,19 @@ import org.jetbrains.kotlin.backend.common.DeclarationTransformer
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
class RemoveInlineFunctionsWithReifiedTypeParametersLowering: DeclarationTransformer {
class RemoveInlineDeclarationsWithReifiedTypeParametersLowering: DeclarationTransformer {
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
fun IrFunction.isInlineFunWithReifiedParameter() = isInline && typeParameters.any { it.isReified }
if (declaration is IrFunction && declaration.isInline && declaration.typeParameters.any { it.isReified }) {
if (declaration is IrFunction && declaration.isInlineFunWithReifiedParameter() ||
declaration is IrProperty && declaration.getter?.isInlineFunWithReifiedParameter() == true
) {
return emptyList()
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering
import org.jetbrains.kotlin.backend.common.phaser.*
import org.jetbrains.kotlin.backend.wasm.lower.*
import org.jetbrains.kotlin.ir.backend.js.lower.*
import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineFunctionsWithReifiedTypeParametersLowering
import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineDeclarationsWithReifiedTypeParametersLowering
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
@@ -96,8 +96,8 @@ private val functionInliningPhase = makeCustomWasmModulePhase(
prerequisite = setOf(expectDeclarationsRemovingPhase)
)
private val removeInlineFunctionsWithReifiedTypeParametersLoweringPhase = makeWasmModulePhase(
{ RemoveInlineFunctionsWithReifiedTypeParametersLowering() },
private val removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase = makeWasmModulePhase(
{ RemoveInlineDeclarationsWithReifiedTypeParametersLowering() },
name = "RemoveInlineFunctionsWithReifiedTypeParametersLowering",
description = "Remove Inline functions with reified parameters from context",
prerequisite = setOf(functionInliningPhase)
@@ -461,7 +461,7 @@ val wasmPhases = NamedCompilerPhase(
defaultArgumentPatchOverridesPhase then
defaultParameterInjectorPhase then
defaultParameterCleanerPhase then
removeInlineFunctionsWithReifiedTypeParametersLoweringPhase then
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase then
// TODO:
// multipleCatchesLoweringPhase then