[IR] Mark IrExpressionBodyImpl with an opt-in annotation
KT-59318
This commit is contained in:
committed by
Space Team
parent
2096d22e18
commit
1b557c1657
+3
-2
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetValueImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
@@ -143,7 +142,9 @@ private class EnumClassLowering(private val context: JvmBackendContext) : ClassL
|
||||
|
||||
private fun buildEnumEntryField(enumEntry: IrEnumEntry): IrField =
|
||||
context.cachedDeclarations.getFieldForEnumEntry(enumEntry).apply {
|
||||
initializer = enumEntry.initializerExpression?.let { IrExpressionBodyImpl(it.expression.patchDeclarationParents(this)) }
|
||||
initializer = enumEntry.initializerExpression?.let {
|
||||
context.irFactory.createExpressionBody(it.expression.patchDeclarationParents(this))
|
||||
}
|
||||
annotations = annotations + enumEntry.annotations
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -214,22 +214,24 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran
|
||||
// Bridge from static to static method - simply fill the function arguments to the parameters.
|
||||
// By nature of the generation of both source and target of bridge, they line up.
|
||||
private fun IrFunction.bridgeToStatic(callTarget: IrSimpleFunction) {
|
||||
body = IrExpressionBodyImpl(IrCallImpl.fromSymbolOwner(startOffset, endOffset, returnType, callTarget.symbol).also { call ->
|
||||
body = context.irFactory.createExpressionBody(
|
||||
IrCallImpl.fromSymbolOwner(startOffset, endOffset, returnType, callTarget.symbol).also { call ->
|
||||
|
||||
callTarget.typeParameters.forEachIndexed { i, _ ->
|
||||
call.putTypeArgument(i, createPlaceholderAnyNType(context.irBuiltIns))
|
||||
}
|
||||
callTarget.typeParameters.forEachIndexed { i, _ ->
|
||||
call.putTypeArgument(i, createPlaceholderAnyNType(context.irBuiltIns))
|
||||
}
|
||||
|
||||
valueParameters.forEachIndexed { i, it ->
|
||||
call.putValueArgument(i, IrGetValueImpl(startOffset, endOffset, it.symbol))
|
||||
}
|
||||
})
|
||||
valueParameters.forEachIndexed { i, it ->
|
||||
call.putValueArgument(i, IrGetValueImpl(startOffset, endOffset, it.symbol))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Bridge from static DefaultImpl method to the interface method. Arguments need to
|
||||
// be shifted in presence of dispatch and extension receiver.
|
||||
private fun IrFunction.bridgeViaAccessorTo(callTarget: IrSimpleFunction) {
|
||||
body = IrExpressionBodyImpl(
|
||||
body = context.irFactory.createExpressionBody(
|
||||
IrCallImpl.fromSymbolOwner(
|
||||
startOffset,
|
||||
endOffset,
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
|
||||
wrapperIrFunction.body = if (target is IrConstructor) {
|
||||
context.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET, listOf(call))
|
||||
} else {
|
||||
IrExpressionBodyImpl(
|
||||
context.irFactory.createExpressionBody(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, call
|
||||
)
|
||||
}
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.addField
|
||||
import org.jetbrains.kotlin.ir.builders.irCall
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl
|
||||
@@ -114,7 +113,7 @@ private class MoveOrCopyCompanionObjectFieldsLowering(val context: JvmBackendCon
|
||||
parent = newParent
|
||||
correspondingPropertySymbol = oldProperty.symbol
|
||||
initializer = oldField.initializer?.run {
|
||||
IrExpressionBodyImpl(startOffset, endOffset, (expression as IrConst<*>).shallowCopy())
|
||||
context.irFactory.createExpressionBody(startOffset, endOffset, (expression as IrConst<*>).shallowCopy())
|
||||
}
|
||||
annotations += oldField.annotations
|
||||
if (oldProperty.parentAsClass.visibility == DescriptorVisibilities.PRIVATE) {
|
||||
|
||||
+5
-1
@@ -94,7 +94,11 @@ internal abstract class SuspendLoweringUtils(protected val context: JvmBackendCo
|
||||
val message = "This is a stub representing a copy of a suspend method without the state machine " +
|
||||
"(used by the inliner). Since the difference is at the bytecode level, the body is " +
|
||||
"still on the original function. Use suspendForInlineToOriginal() to retrieve it."
|
||||
body = IrExpressionBodyImpl(startOffset, endOffset, IrErrorExpressionImpl(startOffset, endOffset, returnType, message))
|
||||
body = context.irFactory.createExpressionBody(
|
||||
startOffset,
|
||||
endOffset,
|
||||
IrErrorExpressionImpl(startOffset, endOffset, returnType, message),
|
||||
)
|
||||
}
|
||||
|
||||
protected fun IrFunction.addCompletionValueParameter(): IrValueParameter =
|
||||
|
||||
+4
-4
@@ -172,7 +172,7 @@ class CachedSyntheticDeclarations(private val context: JvmBackendContext) {
|
||||
JvmLoweredDeclarationOrigin.SYNTHETIC_MARKER_PARAMETER
|
||||
)
|
||||
|
||||
accessor.body = IrExpressionBodyImpl(
|
||||
accessor.body = context.irFactory.createExpressionBody(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
createConstructorCall(accessor, source.symbol)
|
||||
)
|
||||
@@ -208,7 +208,7 @@ class CachedSyntheticDeclarations(private val context: JvmBackendContext) {
|
||||
accessor.copyValueParametersToStatic(source, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR, dispatchReceiverType)
|
||||
accessor.returnType = source.returnType.remapTypeParameters(source, accessor)
|
||||
|
||||
accessor.body = IrExpressionBodyImpl(
|
||||
accessor.body = context.irFactory.createExpressionBody(
|
||||
accessor.startOffset, accessor.startOffset,
|
||||
createSimpleFunctionCall(accessor, source.symbol, superQualifierSymbol)
|
||||
)
|
||||
@@ -270,7 +270,7 @@ class CachedSyntheticDeclarations(private val context: JvmBackendContext) {
|
||||
val maybeDispatchReceiver =
|
||||
if (targetField.isStatic) null
|
||||
else IrGetValueImpl(accessor.startOffset, accessor.endOffset, accessor.valueParameters[0].symbol)
|
||||
return IrExpressionBodyImpl(
|
||||
return context.irFactory.createExpressionBody(
|
||||
accessor.startOffset, accessor.endOffset,
|
||||
IrGetFieldImpl(
|
||||
accessor.startOffset, accessor.endOffset,
|
||||
@@ -332,7 +332,7 @@ class CachedSyntheticDeclarations(private val context: JvmBackendContext) {
|
||||
accessor.startOffset, accessor.endOffset,
|
||||
accessor.valueParameters[if (targetField.isStatic) 0 else 1].symbol
|
||||
)
|
||||
return IrExpressionBodyImpl(
|
||||
return context.irFactory.createExpressionBody(
|
||||
accessor.startOffset, accessor.endOffset,
|
||||
IrSetFieldImpl(
|
||||
accessor.startOffset, accessor.endOffset,
|
||||
|
||||
Reference in New Issue
Block a user