From 831ef0f9092d5db80bf373310f946d0953623be2 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Tue, 6 Feb 2024 15:15:19 +0100 Subject: [PATCH] [FakeOverrideBuilder] Fix referencing a local type from a return type Copying tree part happens in two stages. 1. Collect all symbols to copy and create new version of them 2. Do copy tree, replacing collected symbols For f/o builder 1-st stage traversed more nodes, than seconds. This led to unbound symbols in tree. ^KT-65273 Fixed --- .../FirLightTreeJvmIrTextTestGenerated.java | 6 ++ .../ir/FirPsiJvmIrTextTestGenerated.java | 6 ++ .../CopyIrTreeWithSymbolsForFakeOverrides.kt | 18 +++- .../kotlin/ir/util/DeepCopySymbolRemapper.kt | 34 +++---- .../ir/irText/declarations/kt65273.fir.ir.txt | 97 +++++++++++++++++++ .../ir/irText/declarations/kt65273.fir.kt.txt | 41 ++++++++ .../declarations/kt65273.fir.sig.kt.txt | 68 +++++++++++++ .../ir/irText/declarations/kt65273.ir.txt | 97 +++++++++++++++++++ .../ir/irText/declarations/kt65273.kt | 10 ++ .../ir/irText/declarations/kt65273.kt.txt | 41 ++++++++ .../ir/irText/declarations/kt65273.sig.kt.txt | 66 +++++++++++++ .../ir/ClassicJvmIrTextTestGenerated.java | 6 ++ .../klib/KlibIrTextTestCaseGenerated.java | 5 + .../FirLightTreeJsIrTextTestGenerated.java | 6 ++ .../test/fir/FirPsiJsIrTextTestGenerated.java | 6 ++ .../test/ir/ClassicJsIrTextTestGenerated.java | 6 ++ .../ClassicNativeIrTextTestGenerated.java | 6 ++ ...FirLightTreeNativeIrTextTestGenerated.java | 6 ++ .../FirPsiNativeIrTextTestGenerated.java | 6 ++ 19 files changed, 509 insertions(+), 22 deletions(-) create mode 100644 compiler/testData/ir/irText/declarations/kt65273.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.fir.sig.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.kt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/kt65273.sig.kt.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index 632c51050e5..c5519dd746a 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -552,6 +552,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/declarations/kt65236.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("kt65432.kt") public void testKt65432() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index bd79d3b6720..9f658d72651 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -552,6 +552,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/declarations/kt65236.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("kt65432.kt") public void testKt65432() throws Exception { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/CopyIrTreeWithSymbolsForFakeOverrides.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/CopyIrTreeWithSymbolsForFakeOverrides.kt index 2b966701de3..8bf20b72914 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/CopyIrTreeWithSymbolsForFakeOverrides.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/CopyIrTreeWithSymbolsForFakeOverrides.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.ir.overrides -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrOverridableMember -import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.* @@ -98,6 +99,17 @@ class CopyIrTreeWithSymbolsForFakeOverrides( private val typeArguments: Map, descriptorsRemapper: DescriptorsRemapper ) : DeepCopySymbolRemapper(descriptorsRemapper) { + + // We need to avoid visiting parts of the tree that would not be visited by [FakeOverrideCopier] + // Otherwise, we can record symbols inside them for rebinding, but would not actually copy them. + // Normally, this is not important, as these local symbols would not be used anyway + // But they can be used in return values of functions/accessors if it is effectively a private declaration, + // e.g. public declaration inside a private class. + + override fun visitField(declaration: IrField) {} // don't visit property backing field + override fun visitBlockBody(body: IrBlockBody) {} // don't visit function body and parameter default values + override fun visitExpressionBody(body: IrExpressionBody) {} // don't visit function body and parameter default values + override fun getReferencedClassifier(symbol: IrClassifierSymbol): IrClassifierSymbol { val result = super.getReferencedClassifier(symbol) if (result !is IrTypeParameterSymbol) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt index 9a2b7a96eb2..38dff033d7f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt @@ -53,10 +53,6 @@ open class DeepCopySymbolRemapper( element.acceptChildrenVoid(this) } - override fun visitCall(expression: IrCall) { - expression.acceptChildrenVoid(this) - } - protected inline fun > remapSymbol(map: MutableMap, owner: B, createNewSymbol: (S) -> S) { val symbol = owner.symbol as S @@ -67,98 +63,98 @@ open class DeepCopySymbolRemapper( remapSymbol(classes, declaration) { IrClassSymbolImpl(descriptorsRemapper.remapDeclaredClass(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitClass(declaration) } override fun visitScript(declaration: IrScript) { remapSymbol(scripts, declaration) { IrScriptSymbolImpl(descriptorsRemapper.remapDeclaredScript(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitScript(declaration) } override fun visitConstructor(declaration: IrConstructor) { remapSymbol(constructors, declaration) { IrConstructorSymbolImpl(descriptorsRemapper.remapDeclaredConstructor(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitConstructor(declaration) } override fun visitEnumEntry(declaration: IrEnumEntry) { remapSymbol(enumEntries, declaration) { IrEnumEntrySymbolImpl(descriptorsRemapper.remapDeclaredEnumEntry(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitEnumEntry(declaration) } override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment) { remapSymbol(externalPackageFragments, declaration) { IrExternalPackageFragmentSymbolImpl(descriptorsRemapper.remapDeclaredExternalPackageFragment(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitExternalPackageFragment(declaration) } override fun visitField(declaration: IrField) { remapSymbol(fields, declaration) { IrFieldSymbolImpl(descriptorsRemapper.remapDeclaredField(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitField(declaration) } override fun visitFile(declaration: IrFile) { remapSymbol(files, declaration) { IrFileSymbolImpl(descriptorsRemapper.remapDeclaredFilePackageFragment(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitFile(declaration) } override fun visitSimpleFunction(declaration: IrSimpleFunction) { remapSymbol(functions, declaration) { IrSimpleFunctionSymbolImpl(descriptorsRemapper.remapDeclaredSimpleFunction(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitSimpleFunction(declaration) } override fun visitProperty(declaration: IrProperty) { remapSymbol(properties, declaration) { IrPropertySymbolImpl(descriptorsRemapper.remapDeclaredProperty(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitProperty(declaration) } override fun visitTypeParameter(declaration: IrTypeParameter) { remapSymbol(typeParameters, declaration) { IrTypeParameterSymbolImpl(descriptorsRemapper.remapDeclaredTypeParameter(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitTypeParameter(declaration) } override fun visitValueParameter(declaration: IrValueParameter) { remapSymbol(valueParameters, declaration) { IrValueParameterSymbolImpl(descriptorsRemapper.remapDeclaredValueParameter(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitValueParameter(declaration) } override fun visitVariable(declaration: IrVariable) { remapSymbol(variables, declaration) { IrVariableSymbolImpl(descriptorsRemapper.remapDeclaredVariable(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitVariable(declaration) } override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty) { remapSymbol(localDelegatedProperties, declaration) { IrLocalDelegatedPropertySymbolImpl(descriptorsRemapper.remapDeclaredLocalDelegatedProperty(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitLocalDelegatedProperty(declaration) } override fun visitTypeAlias(declaration: IrTypeAlias) { remapSymbol(typeAliases, declaration) { IrTypeAliasSymbolImpl(descriptorsRemapper.remapDeclaredTypeAlias(it.descriptor)) } - declaration.acceptChildrenVoid(this) + super.visitTypeAlias(declaration) } override fun visitBlock(expression: IrBlock) { @@ -167,7 +163,7 @@ open class DeepCopySymbolRemapper( IrReturnableBlockSymbolImpl() } } - expression.acceptChildrenVoid(this) + super.visitBlock(expression) } private fun Map.getDeclared(symbol: T) = diff --git a/compiler/testData/ir/irText/declarations/kt65273.fir.ir.txt b/compiler/testData/ir/irText/declarations/kt65273.fir.ir.txt new file mode 100644 index 00000000000..ce821864d22 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.fir.ir.txt @@ -0,0 +1,97 @@ +FILE fqName: fileName:/kt65273.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + CONSTRUCTOR visibility:public <> () returnType:.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + CLASS CLASS name:B modality:ABSTRACT visibility:private superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.B + CONSTRUCTOR visibility:public <> () returnType:.A.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:ABSTRACT visibility:private superTypes:[kotlin.Any]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:.A.B.s. visibility:private [final] + EXPRESSION_BODY + BLOCK type=.A.B.s. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.B.s. + CONSTRUCTOR visibility:public <> () returnType:.A.B.s. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any]' + 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 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 + CONSTRUCTOR_CALL 'public constructor () declared in .A.B.s.' type=.A.B.s. origin=OBJECT_LITERAL + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A.B) returnType:.A.B.s. + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.A.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .A.B.s. declared in .A.B' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:.A.B.s. visibility:private [final]' type=.A.B.s. origin=null + receiver: GET_VAR ': .A.B declared in .A.B.' type=.A.B 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 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:C modality:FINAL visibility:private superTypes:[.A.B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.C + CONSTRUCTOR visibility:public <> () returnType:.A.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .A.B' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:private superTypes:[.A.B]' + PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val] + overridden: + public final s: .A.B.s. + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.A.B) returnType:.A.B.s. [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): .A.B.s. declared in .A.B + $this: VALUE_PARAMETER name: type:.A.B + 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 declared in .A.B + $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 .A.B + $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 .A.B + $this: VALUE_PARAMETER name: type:kotlin.Any + 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 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 diff --git a/compiler/testData/ir/irText/declarations/kt65273.fir.kt.txt b/compiler/testData/ir/irText/declarations/kt65273.fir.kt.txt new file mode 100644 index 00000000000..d4487da97d6 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.fir.kt.txt @@ -0,0 +1,41 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + private abstract class B { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: + field = { // BLOCK + local class { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + } + + () + } + get + + } + + private class C : B { + constructor() /* primary */ { + super/*B*/() + /* () */ + + } + + } + +} diff --git a/compiler/testData/ir/irText/declarations/kt65273.fir.sig.kt.txt b/compiler/testData/ir/irText/declarations/kt65273.fir.sig.kt.txt new file mode 100644 index 00000000000..6e4353bf523 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.fir.sig.kt.txt @@ -0,0 +1,68 @@ +// CHECK: +// Mangled name: A +// Public signature: /A|null[0] +class A { + // CHECK: + // Mangled name: A.B + // Public signature: /A.B|null[0] + private abstract class B { + // CHECK: + // Mangled name: A.B{}s + // Public signature: /A.B.s|7217541905509134881[0] + // Public signature debug description: {}s + val s: + // CHECK JS_IR NATIVE: + // Mangled name: A.B#(){} + // Public signature: /A.B.s.|-1662172381559511151[0] + // Public signature debug description: (){} + // CHECK JVM_IR: + // Mangled name (compatible mode: false): A.B#(){}A.B{}s. + // Mangled name (compatible mode: true): A.B#(){}A.B.s. + // Public signature: /A.B.s.|769786868112455262[0] + // Public signature debug description: (){}A.B{}s. + get + + // CHECK: + // Mangled name: A.B#(){} + // Public signature: /A.B.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + + } + + // CHECK: + // Mangled name: A.C + // Public signature: /A.C|null[0] + private class C : B { + // CHECK: + // Mangled name: A.C#(){} + // Public signature: /A.C.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + + // CHECK: + // Mangled name: A.C{}s + // Public signature: /A.C.s|7217541905509134881[0] + // Public signature debug description: {}s + /* fake */ override val s: + // CHECK JS_IR NATIVE: + // Mangled name: A.C#(){} + // Public signature: /A.C.s.|-1662172381559511151[0] + // Public signature debug description: (){} + // CHECK JVM_IR: + // Mangled name (compatible mode: false): A.C#(){}A.B{}s. + // Mangled name (compatible mode: true): A.C#(){}A.B.s. + // Public signature: /A.C.s.|769786868112455262[0] + // Public signature debug description: (){}A.B{}s. + /* fake */ override get(): + + } + + // CHECK: + // Mangled name: A#(){} + // Public signature: /A.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + +} + diff --git a/compiler/testData/ir/irText/declarations/kt65273.ir.txt b/compiler/testData/ir/irText/declarations/kt65273.ir.txt new file mode 100644 index 00000000000..6ec07eec069 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.ir.txt @@ -0,0 +1,97 @@ +FILE fqName: fileName:/kt65273.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + CONSTRUCTOR visibility:public <> () returnType:.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + CLASS CLASS name:B modality:ABSTRACT visibility:private superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.B + CONSTRUCTOR visibility:public <> () returnType:.A.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:ABSTRACT visibility:private superTypes:[kotlin.Any]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + BLOCK type=.A.B.s. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.B.s. + CONSTRUCTOR visibility:public <> () returnType:.A.B.s. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any]' + 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 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 + CONSTRUCTOR_CALL 'public constructor () declared in .A.B.s.' type=.A.B.s. origin=OBJECT_LITERAL + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A.B) returnType:kotlin.Any + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.A.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .A.B' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + receiver: GET_VAR ': .A.B declared in .A.B.' type=.A.B 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 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:C modality:FINAL visibility:private superTypes:[.A.B] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.C + CONSTRUCTOR visibility:public <> () returnType:.A.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .A.B' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:private superTypes:[.A.B]' + PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val] + overridden: + public final s: kotlin.Any + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.A.B) returnType:kotlin.Any [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Any declared in .A.B + $this: VALUE_PARAMETER name: type:.A.B + 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 declared in .A.B + $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 .A.B + $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 .A.B + $this: VALUE_PARAMETER name: type:kotlin.Any + 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 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 diff --git a/compiler/testData/ir/irText/declarations/kt65273.kt b/compiler/testData/ir/irText/declarations/kt65273.kt new file mode 100644 index 00000000000..28817fd62d8 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.kt @@ -0,0 +1,10 @@ +// SEPARATE_SIGNATURE_DUMP_FOR_K2 +// ^ Different type of s - KT-65603 + +class A { + private abstract class B { + val s = object {} + } + + private class C : B() +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/kt65273.kt.txt b/compiler/testData/ir/irText/declarations/kt65273.kt.txt new file mode 100644 index 00000000000..1482206f654 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.kt.txt @@ -0,0 +1,41 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + private abstract class B { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: Any + field = { // BLOCK + local class { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + } + + () + } + get + + } + + private class C : B { + constructor() /* primary */ { + super/*B*/() + /* () */ + + } + + } + +} diff --git a/compiler/testData/ir/irText/declarations/kt65273.sig.kt.txt b/compiler/testData/ir/irText/declarations/kt65273.sig.kt.txt new file mode 100644 index 00000000000..17b46be4913 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt65273.sig.kt.txt @@ -0,0 +1,66 @@ +// CHECK: +// Mangled name: A +// Public signature: /A|null[0] +class A { + // CHECK: + // Mangled name: A.B + // Public signature: /A.B|null[0] + private abstract class B { + // CHECK: + // Mangled name: A.B{}s + // Public signature: /A.B.s|7217541905509134881[0] + // Public signature debug description: {}s + val s: Any + // CHECK JVM_IR: + // Mangled name: A.B#(){}kotlin.Any + // Public signature: /A.B.s.|-6355491283316321221[0] + // Public signature debug description: (){}kotlin.Any + // CHECK JS_IR NATIVE: + // Mangled name: A.B#(){} + // Public signature: /A.B.s.|-1662172381559511151[0] + // Public signature debug description: (){} + get + + // CHECK: + // Mangled name: A.B#(){} + // Public signature: /A.B.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + + } + + // CHECK: + // Mangled name: A.C + // Public signature: /A.C|null[0] + private class C : B { + // CHECK: + // Mangled name: A.C#(){} + // Public signature: /A.C.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + + // CHECK: + // Mangled name: A.C{}s + // Public signature: /A.C.s|7217541905509134881[0] + // Public signature debug description: {}s + /* fake */ override val s: Any + // CHECK JVM_IR: + // Mangled name: A.C#(){}kotlin.Any + // Public signature: /A.C.s.|-6355491283316321221[0] + // Public signature debug description: (){}kotlin.Any + // CHECK JS_IR NATIVE: + // Mangled name: A.C#(){} + // Public signature: /A.C.s.|-1662172381559511151[0] + // Public signature debug description: (){} + /* fake */ override get(): Any + + } + + // CHECK: + // Mangled name: A#(){} + // Public signature: /A.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 2236249f9f6..bb2227ab4ec 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -552,6 +552,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/declarations/kt65236.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("kt65432.kt") public void testKt65432() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java index a43221bda7b..e1e7d763e46 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java @@ -423,6 +423,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase { runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java index c88f07f782d..ea8732e1936 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java index bef79c653d6..94dcc913817 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest { runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java index 223fb735685..b512f480d87 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest { runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java index 39c7e15f3ab..c5989ae21fe 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class ClassicNativeIrTextTestGenerated extends AbstractClassicNativeIrTex runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java index c92efc399f9..a1628f4f181 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class FirLightTreeNativeIrTextTestGenerated extends AbstractFirLightTreeN runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java index cc9bc0b03c7..03a90cc14ed 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java @@ -480,6 +480,12 @@ public class FirPsiNativeIrTextTestGenerated extends AbstractFirPsiNativeIrTextT runTest("compiler/testData/ir/irText/declarations/kt52677.kt"); } + @Test + @TestMetadata("kt65273.kt") + public void testKt65273() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt65273.kt"); + } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception {