[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
This commit is contained in:
Pavel Kunyavskiy
2024-02-06 15:15:19 +01:00
committed by Space Team
parent 90db7cd685
commit 831ef0f909
19 changed files with 509 additions and 22 deletions
@@ -0,0 +1,97 @@
FILE fqName:<root> fileName:/kt65273.kt
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () 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:<this> type:<root>.A.B
CONSTRUCTOR visibility:public <> () returnType:<root>.A.B [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () 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:<root>.A.B.s.<no name provided> visibility:private [final]
EXPRESSION_BODY
BLOCK type=<root>.A.B.s.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A.B.s.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.A.B.s.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> 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:<this> 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:<this> 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:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.B.s.<no name provided>' type=<root>.A.B.s.<no name provided> origin=OBJECT_LITERAL
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-s> visibility:public modality:FINAL <> ($this:<root>.A.B) returnType:<root>.A.B.s.<no name provided>
correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.A.B
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-s> (): <root>.A.B.s.<no name provided> declared in <root>.A.B'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:<root>.A.B.s.<no name provided> visibility:private [final]' type=<root>.A.B.s.<no name provided> origin=null
receiver: GET_VAR '<this>: <root>.A.B declared in <root>.A.B.<get-s>' type=<root>.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:<this> 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:<this> 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:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:private superTypes:[<root>.A.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A.C
CONSTRUCTOR visibility:public <> () returnType:<root>.A.C [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.B'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:private superTypes:[<root>.A.B]'
PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val]
overridden:
public final s: <root>.A.B.s.<no name provided>
FUN FAKE_OVERRIDE name:<get-s> visibility:public modality:FINAL <> ($this:<root>.A.B) returnType:<root>.A.B.s.<no name provided> [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val]
overridden:
public final fun <get-s> (): <root>.A.B.s.<no name provided> declared in <root>.A.B
$this: VALUE_PARAMETER name:<this> type:<root>.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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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:<this> 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:<this> 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:<this> type:kotlin.Any
@@ -0,0 +1,41 @@
class A {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
private abstract class B {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val s: <no name provided>
field = { // BLOCK
local class <no name provided> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
<no name provided>()
}
get
}
private class C : B {
constructor() /* primary */ {
super/*B*/()
/* <init>() */
}
}
}
@@ -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: <no name provided>
// CHECK JS_IR NATIVE:
// Mangled name: A.B#<get-s>(){}
// Public signature: /A.B.s.<get-s>|-1662172381559511151[0]
// Public signature debug description: <get-s>(){}
// CHECK JVM_IR:
// Mangled name (compatible mode: false): A.B#<get-s>(){}A.B{}s.<no name provided>
// Mangled name (compatible mode: true): A.B#<get-s>(){}A.B.s.<no name provided>
// Public signature: /A.B.s.<get-s>|769786868112455262[0]
// Public signature debug description: <get-s>(){}A.B{}s.<no name provided>
get
// CHECK:
// Mangled name: A.B#<init>(){}
// Public signature: /A.B.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: A.C
// Public signature: /A.C|null[0]
private class C : B {
// CHECK:
// Mangled name: A.C#<init>(){}
// Public signature: /A.C.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
// CHECK:
// Mangled name: A.C{}s
// Public signature: /A.C.s|7217541905509134881[0]
// Public signature debug description: {}s
/* fake */ override val s: <no name provided>
// CHECK JS_IR NATIVE:
// Mangled name: A.C#<get-s>(){}
// Public signature: /A.C.s.<get-s>|-1662172381559511151[0]
// Public signature debug description: <get-s>(){}
// CHECK JVM_IR:
// Mangled name (compatible mode: false): A.C#<get-s>(){}A.B{}s.<no name provided>
// Mangled name (compatible mode: true): A.C#<get-s>(){}A.B.s.<no name provided>
// Public signature: /A.C.s.<get-s>|769786868112455262[0]
// Public signature debug description: <get-s>(){}A.B{}s.<no name provided>
/* fake */ override get(): <no name provided>
}
// CHECK:
// Mangled name: A#<init>(){}
// Public signature: /A.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
+97
View File
@@ -0,0 +1,97 @@
FILE fqName:<root> fileName:/kt65273.kt
CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A
CONSTRUCTOR visibility:public <> () returnType:<root>.A [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () 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:<this> type:<root>.A.B
CONSTRUCTOR visibility:public <> () returnType:<root>.A.B [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () 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=<root>.A.B.s.<no name provided> origin=OBJECT_LITERAL
CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A.B.s.<no name provided>
CONSTRUCTOR visibility:public <> () returnType:<root>.A.B.s.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> 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:<this> 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:<this> 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:<this> type:kotlin.Any
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.B.s.<no name provided>' type=<root>.A.B.s.<no name provided> origin=OBJECT_LITERAL
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-s> visibility:public modality:FINAL <> ($this:<root>.A.B) returnType:kotlin.Any
correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.A.B
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-s> (): kotlin.Any declared in <root>.A.B'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null
receiver: GET_VAR '<this>: <root>.A.B declared in <root>.A.B.<get-s>' type=<root>.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:<this> 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:<this> 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:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:private superTypes:[<root>.A.B]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.A.C
CONSTRUCTOR visibility:public <> () returnType:<root>.A.C [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.A.B'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:private superTypes:[<root>.A.B]'
PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val]
overridden:
public final s: kotlin.Any
FUN FAKE_OVERRIDE name:<get-s> visibility:public modality:FINAL <> ($this:<root>.A.B) returnType:kotlin.Any [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:s visibility:public modality:FINAL [fake_override,val]
overridden:
public final fun <get-s> (): kotlin.Any declared in <root>.A.B
$this: VALUE_PARAMETER name:<this> type:<root>.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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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 <root>.A.B
$this: VALUE_PARAMETER name:<this> 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:<this> 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:<this> 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:<this> type:kotlin.Any
+10
View File
@@ -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()
}
+41
View File
@@ -0,0 +1,41 @@
class A {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
private abstract class B {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
val s: Any
field = { // BLOCK
local class <no name provided> {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
<no name provided>()
}
get
}
private class C : B {
constructor() /* primary */ {
super/*B*/()
/* <init>() */
}
}
}
@@ -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#<get-s>(){}kotlin.Any
// Public signature: /A.B.s.<get-s>|-6355491283316321221[0]
// Public signature debug description: <get-s>(){}kotlin.Any
// CHECK JS_IR NATIVE:
// Mangled name: A.B#<get-s>(){}
// Public signature: /A.B.s.<get-s>|-1662172381559511151[0]
// Public signature debug description: <get-s>(){}
get
// CHECK:
// Mangled name: A.B#<init>(){}
// Public signature: /A.B.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}
// CHECK:
// Mangled name: A.C
// Public signature: /A.C|null[0]
private class C : B {
// CHECK:
// Mangled name: A.C#<init>(){}
// Public signature: /A.C.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
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#<get-s>(){}kotlin.Any
// Public signature: /A.C.s.<get-s>|-6355491283316321221[0]
// Public signature debug description: <get-s>(){}kotlin.Any
// CHECK JS_IR NATIVE:
// Mangled name: A.C#<get-s>(){}
// Public signature: /A.C.s.<get-s>|-1662172381559511151[0]
// Public signature debug description: <get-s>(){}
/* fake */ override get(): Any
}
// CHECK:
// Mangled name: A#<init>(){}
// Public signature: /A.<init>|-5645683436151566731[0]
// Public signature debug description: <init>(){}
constructor() /* primary */
}