From 3171129c3ca2d381aba7a3efbca358bec4be7b61 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 17 Apr 2019 16:33:46 +0200 Subject: [PATCH] JS_IR: remove traces of @kotlin.native.internal.InlineConstructor This is a hack used by Kotlin/Native purely to implement Array constructors. Since there's a lowering that does that, and inline constructors are not part of the language (although they theoretically could be), the code is redundant. (cherry picked from commit a74fae246bf6b460793839f32c3ba78e3ff1bfa4) --- .../js/lower/inline/FunctionInlining.kt | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/FunctionInlining.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/FunctionInlining.kt index 1fb5430c57d..dbdde9eb3cd 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/FunctionInlining.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/FunctionInlining.kt @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext -import org.jetbrains.kotlin.ir.builders.irGet import org.jetbrains.kotlin.ir.builders.irReturn import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* @@ -29,7 +28,6 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.util.OperatorNameConventions typealias Context = JsIrBackendContext @@ -90,11 +88,7 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW return (symbol.owner as? IrSimpleFunction)?.resolveFakeOverride() ?: symbol.owner } - private val inlineConstructor = FqName("kotlin.native.internal.InlineConstructor") - - private val IrFunction.isInlineConstructor get() = annotations.hasAnnotation(inlineConstructor) - - private val IrFunction.needsInlining get() = isInlineConstructor || (this.isInline && !this.isExternal) + private val IrFunction.needsInlining get() = (this.isInline && !this.isExternal) private inner class Inliner(val callSite: IrFunctionAccessExpression, val callee: IrFunction, @@ -140,38 +134,6 @@ internal class FunctionInlining(val context: Context): IrElementTransformerVoidW val endOffset = callee.endOffset val irBuilder = context.createIrBuilder(irReturnableBlockSymbol, startOffset, endOffset) - if (callee.isInlineConstructor) { - // Copier sets parent to be the current function but - // constructor's parent cannot be a function. - val constructedClass = callee.parentAsClass - copiedCallee.parent = constructedClass - val delegatingConstructorCall = statements[0] as IrDelegatingConstructorCall - irBuilder.run { - val constructorCall = IrConstructorCallImpl( - startOffset, endOffset, - callSite.type, - delegatingConstructorCall.symbol, delegatingConstructorCall.descriptor, - constructedClass.typeParameters.size, 0, - delegatingConstructorCall.symbol.owner.valueParameters.size - ).apply { - delegatingConstructorCall.symbol.owner.valueParameters.forEach { - putValueArgument(it.index, delegatingConstructorCall.getValueArgument(it.index)) - } - constructedClass.typeParameters.forEach { - putTypeArgument(it.index, delegatingConstructorCall.getTypeArgument(it.index)) - } - } - val oldThis = constructedClass.thisReceiver!! - val newThis = currentScope.scope.createTemporaryVariableWithWrappedDescriptor( - irExpression = constructorCall, - nameHint = constructedClass.fqNameSafe.toString() + ".this" - ) - statements[0] = newThis - substituteMap[oldThis] = irGet(newThis) - statements.add(irReturn(irGet(newThis))) - } - } - val transformer = ParameterSubstitutor() statements.transform { it.transform(transformer, data = null) } statements.addAll(0, evaluationStatements)