JVM IR: Fix line numbers in callable reference classes
This commit is contained in:
committed by
max-kammerer
parent
59f2aa7add
commit
e261b1e2de
+5
-4
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.backend.common.BackendContext
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.IrElementVisitorVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.ScopeWithIr
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.*
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.Scope
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||
@@ -411,9 +412,9 @@ class LocalDeclarationsLowering(
|
||||
0,
|
||||
localClassContext.capturedValueToField.map { (capturedValue, field) ->
|
||||
IrSetFieldImpl(
|
||||
irClass.startOffset, irClass.endOffset, field.symbol,
|
||||
IrGetValueImpl(irClass.startOffset, irClass.endOffset, irClass.thisReceiver!!.symbol),
|
||||
constructorContext.irGet(irClass.startOffset, irClass.endOffset, capturedValue)!!,
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, field.symbol,
|
||||
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irClass.thisReceiver!!.symbol),
|
||||
constructorContext.irGet(UNDEFINED_OFFSET, UNDEFINED_OFFSET, capturedValue)!!,
|
||||
context.irBuiltIns.unitType,
|
||||
STATEMENT_ORIGIN_INITIALIZER_OF_FIELD_FOR_CAPTURED_VALUE
|
||||
)
|
||||
|
||||
+4
-3
@@ -185,7 +185,6 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
|
||||
private fun createConstructor(): IrConstructor =
|
||||
functionReferenceClass.addConstructor {
|
||||
setSourceRange(irFunctionReference)
|
||||
origin = JvmLoweredDeclarationOrigin.GENERATED_MEMBER_IN_CALLABLE_REFERENCE
|
||||
returnType = functionReferenceClass.defaultType
|
||||
isPrimary = true
|
||||
@@ -227,6 +226,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
|
||||
private fun createInvokeMethod(receiverVar: IrValueDeclaration?): IrSimpleFunction =
|
||||
functionReferenceClass.addFunction {
|
||||
setSourceRange(if (isLambda) callee else irFunctionReference)
|
||||
name = superMethod.owner.name
|
||||
returnType = callee.returnType
|
||||
isSuspend = callee.isSuspend
|
||||
@@ -244,8 +244,9 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext)
|
||||
}
|
||||
valueParameters += valueParameterMap.values
|
||||
|
||||
body = context.createIrBuilder(symbol).irBlockBody(startOffset, endOffset) {
|
||||
callee.body?.statements?.forEach { statement ->
|
||||
val calleeBody = callee.body as IrBlockBody
|
||||
body = context.createIrBuilder(symbol).irBlockBody(calleeBody.startOffset, calleeBody.endOffset) {
|
||||
calleeBody.statements.forEach { statement ->
|
||||
+statement.transform(object : IrElementTransformerVoid() {
|
||||
override fun visitGetValue(expression: IrGetValue): IrExpression {
|
||||
val replacement = valueParameterMap[expression.symbol.owner]
|
||||
|
||||
Reference in New Issue
Block a user