Files
kotlin-fork/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt.txt
T
2024-02-16 10:19:38 +00:00

80 lines
2.4 KiB
Kotlin
Vendored

class DeepCopyIrTreeWithSymbols {
private val typeRemapper: TypeRemapper
field = typeRemapper
private get
constructor(typeRemapper: TypeRemapper) /* primary */ {
super/*Any*/()
/* <init>() */
}
private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter {
return declaration
}
fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) {
<this>.<set-typeParameters>(<set-?> = other.<get-typeParameters>().map<IrTypeParameter, IrTypeParameter>(transform = local fun <anonymous>(it: IrTypeParameter): IrTypeParameter {
return <this>.copyTypeParameter(declaration = it)
}
))
<this>.<get-typeRemapper>().withinScope<Unit>(irTypeParametersContainer = <this>, fn = local fun <anonymous>() {
{ // BLOCK
val tmp_0: Iterator<Pair<IrTypeParameter, IrTypeParameter>> = <this>.<get-typeParameters>().zip<IrTypeParameter, IrTypeParameter>(other = other.<get-typeParameters>()).iterator()
while (tmp_0.hasNext()) { // BLOCK
val tmp_1: Pair<IrTypeParameter, IrTypeParameter> = tmp_0.next()
val thisTypeParameter: IrTypeParameter = tmp_1.component1()
val otherTypeParameter: IrTypeParameter = tmp_1.component2()
{ // BLOCK
otherTypeParameter.<get-superTypes>().mapTo<IrType, IrType, MutableList<IrType>>(destination = thisTypeParameter.<get-superTypes>(), transform = local fun <anonymous>(it: IrType): IrType {
return <this>.<get-typeRemapper>().remapType(type = it)
}
) /*~> Unit */
}
}
}
}
)
}
}
interface IrDeclaration {
}
interface IrDeclarationParent {
}
interface IrType {
}
interface IrTypeParameter : IrDeclaration {
abstract val superTypes: MutableList<IrType>
abstract get
}
interface IrTypeParametersContainer : IrDeclaration, IrDeclarationParent {
abstract var typeParameters: List<IrTypeParameter>
abstract get
abstract set
}
interface TypeRemapper {
abstract fun enterScope(irTypeParametersContainer: IrTypeParametersContainer)
abstract fun leaveScope()
abstract fun remapType(type: IrType): IrType
}
inline fun <T : Any?> TypeRemapper.withinScope(irTypeParametersContainer: IrTypeParametersContainer, fn: Function0<T>): T {
<this>.enterScope(irTypeParametersContainer = irTypeParametersContainer)
val result: T = fn.invoke()
<this>.leaveScope()
return result
}