IR: handle varargElementType in LocalDeclarationsLowering
This commit is contained in:
+17
-8
@@ -190,7 +190,15 @@ class LocalDeclarationsLowering(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun LocalContext.remapType(type: IrType): IrType = typeRemapper.remapType(type)
|
private fun LocalContext.remapType(type: IrType): IrType {
|
||||||
|
if (capturedTypeParameterToTypeParameter.isEmpty()) return type
|
||||||
|
return typeRemapper.remapType(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun LocalContext.remapTypes(body: IrBody) {
|
||||||
|
if (capturedTypeParameterToTypeParameter.isEmpty()) return
|
||||||
|
body.remapTypes(typeRemapper)
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
private inner class LocalDeclarationsTransformer(
|
private inner class LocalDeclarationsTransformer(
|
||||||
@@ -223,21 +231,21 @@ class LocalDeclarationsLowering(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun insertLoweredDeclarationForLocalFunctions() {
|
private fun insertLoweredDeclarationForLocalFunctions() {
|
||||||
localFunctions.values.forEach {
|
localFunctions.values.forEach { localContext ->
|
||||||
it.transformedDeclaration.apply {
|
localContext.transformedDeclaration.apply {
|
||||||
val original = it.declaration
|
val original = localContext.declaration
|
||||||
|
|
||||||
this.body = original.body
|
this.body = original.body
|
||||||
this.body?.remapTypes(it.typeRemapper)
|
this.body?.let { localContext.remapTypes(it) }
|
||||||
|
|
||||||
original.valueParameters.filter { v -> v.defaultValue != null }.forEach { argument ->
|
original.valueParameters.filter { v -> v.defaultValue != null }.forEach { argument ->
|
||||||
val body = argument.defaultValue!!
|
val body = argument.defaultValue!!
|
||||||
body.remapTypes(it.typeRemapper)
|
localContext.remapTypes(body)
|
||||||
oldParameterToNew[argument]!!.defaultValue = body
|
oldParameterToNew[argument]!!.defaultValue = body
|
||||||
}
|
}
|
||||||
acceptChildren(SetDeclarationsParentVisitor, this)
|
acceptChildren(SetDeclarationsParentVisitor, this)
|
||||||
}
|
}
|
||||||
it.ownerForLoweredDeclaration.addChild(it.transformedDeclaration)
|
localContext.ownerForLoweredDeclaration.addChild(localContext.transformedDeclaration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +650,8 @@ class LocalDeclarationsLowering(
|
|||||||
v.copyTo(
|
v.copyTo(
|
||||||
newDeclaration,
|
newDeclaration,
|
||||||
index = v.index + capturedValues.size,
|
index = v.index + capturedValues.size,
|
||||||
type = localFunctionContext.remapType(v.type)
|
type = localFunctionContext.remapType(v.type),
|
||||||
|
varargElementType = v.varargElementType?.let { localFunctionContext.remapType(it) }
|
||||||
).also {
|
).also {
|
||||||
newParameterToOld.putAbsentOrSame(it, v)
|
newParameterToOld.putAbsentOrSame(it, v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private class RemapTypesHelper(private val typeRemapper: TypeRemapper) : IrEleme
|
|||||||
|
|
||||||
override fun visitValueParameter(declaration: IrValueParameter) {
|
override fun visitValueParameter(declaration: IrValueParameter) {
|
||||||
declaration.type = typeRemapper.remapType(declaration.type)
|
declaration.type = typeRemapper.remapType(declaration.type)
|
||||||
|
declaration.varargElementType = declaration.varargElementType?.let { typeRemapper.remapType(it) }
|
||||||
super.visitValueParameter(declaration)
|
super.visitValueParameter(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user