diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.kt new file mode 100644 index 00000000000..85c56ffbe3a --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.kt @@ -0,0 +1,42 @@ +interface IrType + +interface TypeRemapper { + fun enterScope(irTypeParametersContainer: IrTypeParametersContainer) + fun remapType(type: IrType): IrType + fun leaveScope() +} + +interface IrTypeParametersContainer : IrDeclaration, IrDeclarationParent { + var typeParameters: List +} + +interface IrDeclaration +interface IrTypeParameter : IrDeclaration { + val superTypes: MutableList +} +interface IrDeclarationParent + +class DeepCopyIrTreeWithSymbols(private val typeRemapper: TypeRemapper) { + private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter = declaration + + fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) { + this.typeParameters = other.typeParameters.map { + copyTypeParameter(it) + } + + typeRemapper.withinScope(this) { + for ((thisTypeParameter, otherTypeParameter) in this.typeParameters.zip(other.typeParameters)) { + otherTypeParameter.superTypes.mapTo(thisTypeParameter.superTypes) { + typeRemapper.remapType(it) + } + } + } + } +} + +inline fun TypeRemapper.withinScope(irTypeParametersContainer: IrTypeParametersContainer, fn: () -> T): T { + enterScope(irTypeParametersContainer) + val result = fn() + leaveScope() + return result +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.txt new file mode 100644 index 00000000000..010089f66d6 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.txt @@ -0,0 +1,66 @@ +FILE: DeepCopyIrTree.kt + public abstract interface IrType : R|kotlin/Any| { + } + public abstract interface TypeRemapper : R|kotlin/Any| { + public abstract fun enterScope(irTypeParametersContainer: R|IrTypeParametersContainer|): R|kotlin/Unit| + + public abstract fun remapType(type: R|IrType|): R|IrType| + + public abstract fun leaveScope(): R|kotlin/Unit| + + } + public abstract interface IrTypeParametersContainer : R|IrDeclaration|, R|IrDeclarationParent| { + public abstract var typeParameters: R|kotlin/collections/List| + public get(): R|kotlin/collections/List| + public set(value: R|kotlin/collections/List|): R|kotlin/Unit| + + } + public abstract interface IrDeclaration : R|kotlin/Any| { + } + public abstract interface IrTypeParameter : R|IrDeclaration| { + public abstract val superTypes: R|kotlin/collections/MutableList| + public get(): R|kotlin/collections/MutableList| + + } + public abstract interface IrDeclarationParent : R|kotlin/Any| { + } + public final class DeepCopyIrTreeWithSymbols : R|kotlin/Any| { + public constructor(typeRemapper: R|TypeRemapper|): R|DeepCopyIrTreeWithSymbols| { + super() + } + + private final val typeRemapper: R|TypeRemapper| = R|/typeRemapper| + private get(): R|TypeRemapper| + + private final fun copyTypeParameter(declaration: R|IrTypeParameter|): R|IrTypeParameter| { + ^copyTypeParameter R|/declaration| + } + + public final fun R|IrTypeParametersContainer|.copyTypeParametersFrom(other: R|IrTypeParametersContainer|): R|kotlin/Unit| { + this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|.R|/IrTypeParametersContainer.typeParameters| = R|/other|.R|/IrTypeParametersContainer.typeParameters|.R|kotlin/collections/map|( = map@fun (it: R|IrTypeParameter|): R|IrTypeParameter| { + ^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.copyTypeParameter|(R|/it|) + } + ) + this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/withinScope|(this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|, = withinScope@fun (): R|kotlin/Unit| { + lval : R|kotlin/collections/Iterator>| = this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|.R|/IrTypeParametersContainer.typeParameters|.R|kotlin/collections/zip|(R|/other|.R|/IrTypeParametersContainer.typeParameters|).R|FakeOverride>|>|() + while(R|/|.R|kotlin/collections/Iterator.hasNext|()) { + lval : R|kotlin/Pair| = R|/|.R|FakeOverride|>|() + lval thisTypeParameter: R|IrTypeParameter| = R|/|.R|FakeOverride|() + lval otherTypeParameter: R|IrTypeParameter| = R|/|.R|FakeOverride|() + R|/otherTypeParameter|.R|/IrTypeParameter.superTypes|.R|kotlin/collections/mapTo||>(R|/thisTypeParameter|.R|/IrTypeParameter.superTypes|, = mapTo@fun (it: R|IrType|): R|IrType| { + ^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/TypeRemapper.remapType|(R|/it|) + } + ) + } + + } + ) + } + + } + public final inline fun R|TypeRemapper|.withinScope(irTypeParametersContainer: R|IrTypeParametersContainer|, fn: R|() -> T|): R|T| { + this@R|/withinScope|.R|/TypeRemapper.enterScope|(R|/irTypeParametersContainer|) + lval result: R|T| = R|/fn|.R|FakeOverride|() + this@R|/withinScope|.R|/TypeRemapper.leaveScope|() + ^withinScope R|/result| + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index 6290b4c9af5..dc707afc699 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -1184,6 +1184,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("DeepCopyIrTree.kt") + public void testDeepCopyIrTree() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.kt"); + } + @TestMetadata("invokePriority.kt") public void testInvokePriority() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/invokePriority.kt"); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 95ff46af544..b70c2fd7478 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1712,6 +1712,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @TestMetadata("DeepCopyIrTree.kt") + public void testDeepCopyIrTree() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt"); + } + @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt index 16d88ab8406..fb1cd0eb55c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt @@ -33,23 +33,25 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran // ------------------------------- Loops ------------------------------- override fun transformWhileLoop(whileLoop: FirWhileLoop, data: ResolutionMode): CompositeTransformResult { + val context = ResolutionMode.ContextIndependent return whileLoop.also(dataFlowAnalyzer::enterWhileLoop) - .transformCondition(transformer, data).also(dataFlowAnalyzer::exitWhileLoopCondition) - .transformBlock(transformer, data).also(dataFlowAnalyzer::exitWhileLoop) - .transformOtherChildren(transformer, data).compose() + .transformCondition(transformer, context).also(dataFlowAnalyzer::exitWhileLoopCondition) + .transformBlock(transformer, context).also(dataFlowAnalyzer::exitWhileLoop) + .transformOtherChildren(transformer, context).compose() } override fun transformDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: ResolutionMode): CompositeTransformResult { + val context = ResolutionMode.ContextIndependent // Do-while has a specific scope structure (its block and condition effectively share the scope) return withNewLocalScope { doWhileLoop.also(dataFlowAnalyzer::enterDoWhileLoop) .apply { - transformer.expressionsTransformer.transformBlockInCurrentScope(block, data) + transformer.expressionsTransformer.transformBlockInCurrentScope(block, context) dataFlowAnalyzer } - .also(dataFlowAnalyzer::enterDoWhileLoopCondition).transformCondition(transformer, data) + .also(dataFlowAnalyzer::enterDoWhileLoopCondition).transformCondition(transformer, context) .also(dataFlowAnalyzer::exitDoWhileLoop) - .transformOtherChildren(transformer, data).compose() + .transformOtherChildren(transformer, context).compose() } } diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt new file mode 100644 index 00000000000..1d78fd43613 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt @@ -0,0 +1,232 @@ +FILE fqName: fileName:/DeepCopyIrTree.kt + CLASS INTERFACE name:IrType modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrType + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:TypeRemapper modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TypeRemapper + FUN name:enterScope visibility:public modality:ABSTRACT <> ($this:.TypeRemapper, irTypeParametersContainer:.IrTypeParametersContainer) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:irTypeParametersContainer index:0 type:.IrTypeParametersContainer + FUN name:remapType visibility:public modality:ABSTRACT <> ($this:.TypeRemapper, type:.IrType) returnType:.IrType + $this: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:type index:0 type:.IrType + FUN name:leaveScope visibility:public modality:ABSTRACT <> ($this:.TypeRemapper) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.TypeRemapper + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrTypeParametersContainer modality:ABSTRACT visibility:public superTypes:[.IrDeclaration; .IrDeclarationParent] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrTypeParametersContainer + PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParametersContainer) returnType:kotlin.collections.List<.IrTypeParameter> + correspondingProperty: PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IrTypeParametersContainer + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParametersContainer, :kotlin.collections.List<.IrTypeParameter>) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IrTypeParametersContainer + VALUE_PARAMETER name: index:0 type:kotlin.collections.List<.IrTypeParameter> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrDeclaration modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclaration + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrTypeParameter modality:ABSTRACT visibility:public superTypes:[.IrDeclaration] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrTypeParameter + PROPERTY name:superTypes visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParameter) returnType:kotlin.collections.MutableList<.IrType> + correspondingProperty: PROPERTY name:superTypes visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.IrTypeParameter + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrDeclarationParent modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclarationParent + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:DeepCopyIrTreeWithSymbols modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DeepCopyIrTreeWithSymbols + CONSTRUCTOR visibility:public <> (typeRemapper:.TypeRemapper) returnType:.DeepCopyIrTreeWithSymbols [primary] + VALUE_PARAMETER name:typeRemapper index:0 type:.TypeRemapper + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DeepCopyIrTreeWithSymbols modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:typeRemapper visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:typeRemapper type:.TypeRemapper visibility:private [final] + EXPRESSION_BODY + GET_VAR 'typeRemapper: .TypeRemapper declared in .DeepCopyIrTreeWithSymbols.' type=.TypeRemapper origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols) returnType:.TypeRemapper + correspondingProperty: PROPERTY name:typeRemapper visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:typeRemapper type:.TypeRemapper visibility:private [final]' type=.TypeRemapper origin=null + receiver: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.' type=.DeepCopyIrTreeWithSymbols origin=null + FUN name:copyTypeParameter visibility:private modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols, declaration:.IrTypeParameter) returnType:.IrTypeParameter + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + VALUE_PARAMETER name:declaration index:0 type:.IrTypeParameter + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun copyTypeParameter (declaration: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols' + GET_VAR 'declaration: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParameter' type=.IrTypeParameter origin=null + FUN name:copyTypeParametersFrom visibility:public modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols, $receiver:.IrTypeParametersContainer, other:.IrTypeParametersContainer) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + $receiver: VALUE_PARAMETER name: type:.IrTypeParametersContainer + VALUE_PARAMETER name:other index:0 type:.IrTypeParametersContainer + BLOCK_BODY + CALL 'public abstract fun (: kotlin.collections.List<.IrTypeParameter>): kotlin.Unit declared in .IrTypeParametersContainer' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.IrTypeParameter> origin=null + : .IrTypeParameter + : .IrTypeParameter + $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR 'other: .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + transform: FUN_EXPR type=kotlin.Function1<.IrTypeParameter, .IrTypeParameter> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrTypeParameter) returnType:.IrTypeParameter + VALUE_PARAMETER name:it index:0 type:.IrTypeParameter + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' + CALL 'private final fun copyTypeParameter (declaration: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols' type=.IrTypeParameter origin=null + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + declaration: GET_VAR 'it: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + CALL 'public final fun withinScope (irTypeParametersContainer: .IrTypeParametersContainer, fn: kotlin.Function0.withinScope>): T of .withinScope [inline] declared in ' type=kotlin.Unit origin=null + : kotlin.Unit + $receiver: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + irTypeParametersContainer: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] + CALL 'public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.List' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null + : .IrTypeParameter + : .IrTypeParameter + $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + other: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR 'other: .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=null + body: BLOCK type=kotlin.collections.MutableList<.IrType> origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name: type:kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=null + VAR name:thisTypeParameter type:.IrTypeParameter [val] + CALL 'public final fun component1 (): A of kotlin.Pair [operator] declared in kotlin.Pair' type=.IrTypeParameter origin=null + $this: GET_VAR 'val : kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null + VAR name:otherTypeParameter type:.IrTypeParameter [val] + CALL 'public final fun component2 (): B of kotlin.Pair [operator] declared in kotlin.Pair' type=.IrTypeParameter origin=null + $this: GET_VAR 'val : kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null + CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo [inline] declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null + : .IrType + : .IrType + : kotlin.collections.MutableList<.IrType> + $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val otherTypeParameter: .IrTypeParameter [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + destination: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val thisTypeParameter: .IrTypeParameter [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + transform: FUN_EXPR type=kotlin.Function1<.IrType, .IrType> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrType) returnType:.IrType + VALUE_PARAMETER name:it index:0 type:.IrType + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .IrType): .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' + CALL 'public abstract fun remapType (type: .IrType): .IrType declared in .TypeRemapper' type=.IrType origin=null + $this: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + type: GET_VAR 'it: .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom..' type=.IrType origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:withinScope visibility:public modality:FINAL ($receiver:.TypeRemapper, irTypeParametersContainer:.IrTypeParametersContainer, fn:kotlin.Function0.withinScope>) returnType:T of .withinScope [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:irTypeParametersContainer index:0 type:.IrTypeParametersContainer + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.withinScope> + BLOCK_BODY + CALL 'public abstract fun enterScope (irTypeParametersContainer: .IrTypeParametersContainer): kotlin.Unit declared in .TypeRemapper' type=kotlin.Unit origin=null + $this: GET_VAR ': .TypeRemapper declared in .withinScope' type=.TypeRemapper origin=null + irTypeParametersContainer: GET_VAR 'irTypeParametersContainer: .IrTypeParametersContainer declared in .withinScope' type=.IrTypeParametersContainer origin=null + VAR name:result type:T of .withinScope [val] + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .withinScope origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.withinScope> declared in .withinScope' type=kotlin.Function0.withinScope> origin=null + CALL 'public abstract fun leaveScope (): kotlin.Unit declared in .TypeRemapper' type=kotlin.Unit origin=null + $this: GET_VAR ': .TypeRemapper declared in .withinScope' type=.TypeRemapper origin=null + RETURN type=kotlin.Nothing from='public final fun withinScope (irTypeParametersContainer: .IrTypeParametersContainer, fn: kotlin.Function0.withinScope>): T of .withinScope [inline] declared in ' + GET_VAR 'val result: T of .withinScope [val] declared in .withinScope' type=T of .withinScope origin=null diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt new file mode 100644 index 00000000000..d39e2f077df --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt @@ -0,0 +1,45 @@ +// WITH_RUNTIME +// FULL_JDK + +interface IrType + +interface TypeRemapper { + fun enterScope(irTypeParametersContainer: IrTypeParametersContainer) + fun remapType(type: IrType): IrType + fun leaveScope() +} + +interface IrTypeParametersContainer : IrDeclaration, IrDeclarationParent { + var typeParameters: List +} + +interface IrDeclaration +interface IrTypeParameter : IrDeclaration { + val superTypes: MutableList +} +interface IrDeclarationParent + +class DeepCopyIrTreeWithSymbols(private val typeRemapper: TypeRemapper) { + private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter = declaration + + fun IrTypeParametersContainer.copyTypeParametersFrom(other: IrTypeParametersContainer) { + this.typeParameters = other.typeParameters.map { + copyTypeParameter(it) + } + + typeRemapper.withinScope(this) { + for ((thisTypeParameter, otherTypeParameter) in this.typeParameters.zip(other.typeParameters)) { + otherTypeParameter.superTypes.mapTo(thisTypeParameter.superTypes) { + typeRemapper.remapType(it) + } + } + } + } +} + +inline fun TypeRemapper.withinScope(irTypeParametersContainer: IrTypeParametersContainer, fn: () -> T): T { + enterScope(irTypeParametersContainer) + val result = fn() + leaveScope() + return result +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt new file mode 100644 index 00000000000..83dcadb2d47 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt @@ -0,0 +1,237 @@ +FILE fqName: fileName:/DeepCopyIrTree.kt + CLASS INTERFACE name:IrType modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrType + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:TypeRemapper modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TypeRemapper + FUN name:enterScope visibility:public modality:ABSTRACT <> ($this:.TypeRemapper, irTypeParametersContainer:.IrTypeParametersContainer) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:irTypeParametersContainer index:0 type:.IrTypeParametersContainer + FUN name:remapType visibility:public modality:ABSTRACT <> ($this:.TypeRemapper, type:.IrType) returnType:.IrType + $this: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:type index:0 type:.IrType + FUN name:leaveScope visibility:public modality:ABSTRACT <> ($this:.TypeRemapper) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.TypeRemapper + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrTypeParametersContainer modality:ABSTRACT visibility:public superTypes:[.IrDeclaration; .IrDeclarationParent] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrTypeParametersContainer + PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParametersContainer) returnType:kotlin.collections.List<.IrTypeParameter> + correspondingProperty: PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IrTypeParametersContainer + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParametersContainer, :kotlin.collections.List<.IrTypeParameter>) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:typeParameters visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.IrTypeParametersContainer + VALUE_PARAMETER name: index:0 type:kotlin.collections.List<.IrTypeParameter> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclaration + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclarationParent + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclaration + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclarationParent + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclaration + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclarationParent + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrDeclaration modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclaration + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrTypeParameter modality:ABSTRACT visibility:public superTypes:[.IrDeclaration] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrTypeParameter + PROPERTY name:superTypes visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.IrTypeParameter) returnType:kotlin.collections.MutableList<.IrType> + correspondingProperty: PROPERTY name:superTypes visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.IrTypeParameter + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclaration + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclaration + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclaration + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:IrDeclarationParent modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclarationParent + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:DeepCopyIrTreeWithSymbols modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DeepCopyIrTreeWithSymbols + CONSTRUCTOR visibility:public <> (typeRemapper:.TypeRemapper) returnType:.DeepCopyIrTreeWithSymbols [primary] + VALUE_PARAMETER name:typeRemapper index:0 type:.TypeRemapper + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DeepCopyIrTreeWithSymbols modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:typeRemapper visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:typeRemapper type:.TypeRemapper visibility:private [final] + EXPRESSION_BODY + GET_VAR 'typeRemapper: .TypeRemapper declared in .DeepCopyIrTreeWithSymbols.' type=.TypeRemapper origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols) returnType:.TypeRemapper + correspondingProperty: PROPERTY name:typeRemapper visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:typeRemapper type:.TypeRemapper visibility:private [final]' type=.TypeRemapper origin=null + receiver: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.' type=.DeepCopyIrTreeWithSymbols origin=null + FUN name:copyTypeParameter visibility:private modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols, declaration:.IrTypeParameter) returnType:.IrTypeParameter + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + VALUE_PARAMETER name:declaration index:0 type:.IrTypeParameter + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun copyTypeParameter (declaration: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols' + GET_VAR 'declaration: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParameter' type=.IrTypeParameter origin=null + FUN name:copyTypeParametersFrom visibility:public modality:FINAL <> ($this:.DeepCopyIrTreeWithSymbols, $receiver:.IrTypeParametersContainer, other:.IrTypeParametersContainer) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.DeepCopyIrTreeWithSymbols + $receiver: VALUE_PARAMETER name: type:.IrTypeParametersContainer + VALUE_PARAMETER name:other index:0 type:.IrTypeParametersContainer + BLOCK_BODY + CALL 'public abstract fun (: kotlin.collections.List<.IrTypeParameter>): kotlin.Unit declared in .IrTypeParametersContainer' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.IrTypeParameter> origin=null + : .IrTypeParameter + : .IrTypeParameter + $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR 'other: .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + transform: FUN_EXPR type=kotlin.Function1<.IrTypeParameter, .IrTypeParameter> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrTypeParameter) returnType:.IrTypeParameter + VALUE_PARAMETER name:it index:0 type:.IrTypeParameter + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' + CALL 'private final fun copyTypeParameter (declaration: .IrTypeParameter): .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols' type=.IrTypeParameter origin=null + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + declaration: GET_VAR 'it: .IrTypeParameter declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + CALL 'public final fun withinScope (irTypeParametersContainer: .IrTypeParametersContainer, fn: kotlin.Function0.withinScope>): T of .withinScope [inline] declared in ' type=kotlin.Unit origin=null + : kotlin.Unit + $receiver: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + irTypeParametersContainer: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] + CALL 'public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.List' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null + : .IrTypeParameter + : .IrTypeParameter + $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + other: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY + $this: GET_VAR 'other: .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=null + VAR name:thisTypeParameter type:.IrTypeParameter [val] + CALL 'public final fun component1 (): A of kotlin.Pair [operator] declared in kotlin.Pair' type=.IrTypeParameter origin=COMPONENT_N(index=1) + $this: GET_VAR 'val tmp_1: kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null + VAR name:otherTypeParameter type:.IrTypeParameter [val] + CALL 'public final fun component2 (): B of kotlin.Pair [operator] declared in kotlin.Pair' type=.IrTypeParameter origin=COMPONENT_N(index=2) + $this: GET_VAR 'val tmp_1: kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null + BLOCK type=kotlin.Unit origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo [inline] declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null + : .IrType + : .IrType + : kotlin.collections.MutableList<.IrType> + $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val otherTypeParameter: .IrTypeParameter [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + destination: CALL 'public abstract fun (): kotlin.collections.MutableList<.IrType> declared in .IrTypeParameter' type=kotlin.collections.MutableList<.IrType> origin=GET_PROPERTY + $this: GET_VAR 'val thisTypeParameter: .IrTypeParameter [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=.IrTypeParameter origin=null + transform: FUN_EXPR type=kotlin.Function1<.IrType, .IrType> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IrType) returnType:.IrType + VALUE_PARAMETER name:it index:0 type:.IrType + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .IrType): .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' + CALL 'public abstract fun remapType (type: .IrType): .IrType declared in .TypeRemapper' type=.IrType origin=null + $this: CALL 'private final fun (): .TypeRemapper declared in .DeepCopyIrTreeWithSymbols' type=.TypeRemapper origin=GET_PROPERTY + $this: GET_VAR ': .DeepCopyIrTreeWithSymbols declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.DeepCopyIrTreeWithSymbols origin=null + type: GET_VAR 'it: .IrType declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom..' type=.IrType origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:withinScope visibility:public modality:FINAL ($receiver:.TypeRemapper, irTypeParametersContainer:.IrTypeParametersContainer, fn:kotlin.Function0.withinScope>) returnType:T of .withinScope [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.TypeRemapper + VALUE_PARAMETER name:irTypeParametersContainer index:0 type:.IrTypeParametersContainer + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.withinScope> + BLOCK_BODY + CALL 'public abstract fun enterScope (irTypeParametersContainer: .IrTypeParametersContainer): kotlin.Unit declared in .TypeRemapper' type=kotlin.Unit origin=null + $this: GET_VAR ': .TypeRemapper declared in .withinScope' type=.TypeRemapper origin=null + irTypeParametersContainer: GET_VAR 'irTypeParametersContainer: .IrTypeParametersContainer declared in .withinScope' type=.IrTypeParametersContainer origin=null + VAR name:result type:T of .withinScope [val] + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .withinScope origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.withinScope> declared in .withinScope' type=kotlin.Function0.withinScope> origin=VARIABLE_AS_FUNCTION + CALL 'public abstract fun leaveScope (): kotlin.Unit declared in .TypeRemapper' type=kotlin.Unit origin=null + $this: GET_VAR ': .TypeRemapper declared in .withinScope' type=.TypeRemapper origin=null + RETURN type=kotlin.Nothing from='public final fun withinScope (irTypeParametersContainer: .IrTypeParametersContainer, fn: kotlin.Function0.withinScope>): T of .withinScope [inline] declared in ' + GET_VAR 'val result: T of .withinScope [val] declared in .withinScope' type=T of .withinScope origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 15068dfb356..90c639365b0 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1711,6 +1711,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @TestMetadata("DeepCopyIrTree.kt") + public void testDeepCopyIrTree() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt"); + } + @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt");