[FIR2IR] Automatically store IR declaration in its parent upon creation

Previously, creating a declaration with Fir2IrCallableDeclarationsGenerator/
  Fir2IrClassifiersGenerator didn't guarantee that this declaration will
  be actually added to the list of parent class/file declarations, which
  lead to situations when FIR2IR created some declarations in the air
  (mostly fake-overrides)
This commit is contained in:
Dmitriy Novozhilov
2023-10-05 12:39:13 +03:00
committed by Space Team
parent 22f55b3dc4
commit 3d6ec0ec75
96 changed files with 417 additions and 2062 deletions
@@ -62,6 +62,9 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DFoo modality:FINAL visibility:public superTypes:[<root>.IFoo]'
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]
EXPRESSION_BODY
GET_VAR 'd: <root>.IFoo declared in <root>.DFoo.<init>' type=<root>.IFoo origin=null
FUN DELEGATED_MEMBER name:testFun visibility:public modality:OPEN <> ($this:<root>.DFoo) returnType:kotlin.Unit
annotations:
Ann
@@ -112,9 +115,6 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.DFoo declared in <root>.DFoo.<get-testExtVal>' type=<root>.DFoo origin=null
$receiver: GET_VAR '<this>: kotlin.String declared in <root>.DFoo.<get-testExtVal>' type=kotlin.String origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]
EXPRESSION_BODY
GET_VAR 'd: <root>.IFoo declared in <root>.DFoo.<init>' type=<root>.IFoo 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 <root>.IFoo
@@ -31,6 +31,7 @@ class DFoo : IFoo {
}
private /* final field */ val $$delegate_0: IFoo = d
@Ann
override fun testFun() {
<this>.#$$delegate_0.testFun()
@@ -51,6 +52,5 @@ class DFoo : IFoo {
return (<this>.#$$delegate_0, <this>).<get-testExtVal>()
}
private /* final field */ val $$delegate_0: IFoo = d
}
@@ -1,168 +0,0 @@
FILE fqName:<root> fileName:/inheritingDeprecation.kt
CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IFoo
PROPERTY name:prop visibility:public modality:OPEN [val]
annotations:
Deprecated(message = '', replaceWith = <null>, level = <null>)
FUN name:<get-prop> visibility:public modality:OPEN <> ($this:<root>.IFoo) returnType:kotlin.String
correspondingProperty: PROPERTY name:prop visibility:public modality:OPEN [val]
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-prop> (): kotlin.String declared in <root>.IFoo'
CONST String type=kotlin.String value=""
PROPERTY name:extProp visibility:public modality:OPEN [val]
annotations:
Deprecated(message = '', replaceWith = <null>, level = <null>)
FUN name:<get-extProp> visibility:public modality:OPEN <> ($this:<root>.IFoo, $receiver:kotlin.String) returnType:kotlin.String
correspondingProperty: PROPERTY name:extProp visibility:public modality:OPEN [val]
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-extProp> (): kotlin.String declared in <root>.IFoo'
CONST String type=kotlin.String value=""
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:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Delegated
CONSTRUCTOR visibility:public <> (foo:<root>.IFoo) returnType:<root>.Delegated [primary]
VALUE_PARAMETER name:foo index:0 type:<root>.IFoo
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]'
PROPERTY DELEGATED_MEMBER name:prop visibility:public modality:OPEN [val]
overridden:
public open prop: kotlin.String
FUN DELEGATED_MEMBER name:<get-prop> visibility:public modality:OPEN <> ($this:<root>.Delegated) returnType:kotlin.String
correspondingProperty: PROPERTY DELEGATED_MEMBER name:prop visibility:public modality:OPEN [val]
overridden:
public open fun <get-prop> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.Delegated
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-prop> (): kotlin.String declared in <root>.Delegated'
CALL 'public open fun <get-prop> (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated.<get-prop>' type=<root>.Delegated origin=null
PROPERTY DELEGATED_MEMBER name:extProp visibility:public modality:OPEN [val]
overridden:
public open extProp: kotlin.String
FUN DELEGATED_MEMBER name:<get-extProp> visibility:public modality:OPEN <> ($this:<root>.Delegated, $receiver:kotlin.String) returnType:kotlin.String
correspondingProperty: PROPERTY DELEGATED_MEMBER name:extProp visibility:public modality:OPEN [val]
overridden:
public open fun <get-extProp> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.Delegated
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-extProp> (): kotlin.String declared in <root>.Delegated'
CALL 'public open fun <get-extProp> (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]' type=<root>.IFoo origin=null
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated.<get-extProp>' type=<root>.Delegated origin=null
$receiver: GET_VAR '<this>: kotlin.String declared in <root>.Delegated.<get-extProp>' type=kotlin.String origin=null
FIELD DELEGATE name:$$delegate_0 type:<root>.IFoo visibility:private [final]
EXPRESSION_BODY
GET_VAR 'foo: <root>.IFoo declared in <root>.Delegated.<init>' type=<root>.IFoo 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 <root>.IFoo
$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>.IFoo
$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>.IFoo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:DefaultImpl modality:FINAL visibility:public superTypes:[<root>.IFoo]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.DefaultImpl
CONSTRUCTOR visibility:public <> () returnType:<root>.DefaultImpl [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DefaultImpl modality:FINAL visibility:public superTypes:[<root>.IFoo]'
PROPERTY FAKE_OVERRIDE name:prop visibility:public modality:OPEN [fake_override,val]
annotations:
Deprecated(message = '', replaceWith = <null>, level = <null>)
overridden:
public open prop: kotlin.String
FUN FAKE_OVERRIDE name:<get-prop> visibility:public modality:OPEN <> ($this:<root>.IFoo) returnType:kotlin.String [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:prop visibility:public modality:OPEN [fake_override,val]
overridden:
public open fun <get-prop> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
PROPERTY FAKE_OVERRIDE name:extProp visibility:public modality:OPEN [fake_override,val]
annotations:
Deprecated(message = '', replaceWith = <null>, level = <null>)
overridden:
public open extProp: kotlin.String
FUN FAKE_OVERRIDE name:<get-extProp> visibility:public modality:OPEN <> ($this:<root>.IFoo, $receiver:kotlin.String) returnType:kotlin.String [fake_override]
correspondingProperty: PROPERTY FAKE_OVERRIDE name:extProp visibility:public modality:OPEN [fake_override,val]
overridden:
public open fun <get-extProp> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
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>.IFoo
$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>.IFoo
$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>.IFoo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:ExplicitOverride modality:FINAL visibility:public superTypes:[<root>.IFoo]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.ExplicitOverride
CONSTRUCTOR visibility:public <> () returnType:<root>.ExplicitOverride [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ExplicitOverride modality:FINAL visibility:public superTypes:[<root>.IFoo]'
PROPERTY name:prop visibility:public modality:OPEN [val]
overridden:
public open prop: kotlin.String
FUN name:<get-prop> visibility:public modality:OPEN <> ($this:<root>.ExplicitOverride) returnType:kotlin.String
correspondingProperty: PROPERTY name:prop visibility:public modality:OPEN [val]
overridden:
public open fun <get-prop> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.ExplicitOverride
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-prop> (): kotlin.String declared in <root>.ExplicitOverride'
CONST String type=kotlin.String value=""
PROPERTY name:extProp visibility:public modality:OPEN [val]
overridden:
public open extProp: kotlin.String
FUN name:<get-extProp> visibility:public modality:OPEN <> ($this:<root>.ExplicitOverride, $receiver:kotlin.String) returnType:kotlin.String
correspondingProperty: PROPERTY name:extProp visibility:public modality:OPEN [val]
overridden:
public open fun <get-extProp> (): kotlin.String declared in <root>.IFoo
$this: VALUE_PARAMETER name:<this> type:<root>.ExplicitOverride
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-extProp> (): kotlin.String declared in <root>.ExplicitOverride'
CONST String type=kotlin.String value=""
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>.IFoo
$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>.IFoo
$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>.IFoo
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -1,63 +0,0 @@
interface IFoo {
@Deprecated(message = "")
val prop: String
get(): String {
return ""
}
@Deprecated(message = "")
val String.extProp: String
get(): String {
return ""
}
}
class Delegated : IFoo {
constructor(foo: IFoo) /* primary */ {
super/*Any*/()
/* <init>() */
}
override val prop: String
override get(): String {
return <this>.#$$delegate_0.<get-prop>()
}
override val String.extProp: String
override get(): String {
return (<this>.#$$delegate_0, <this>).<get-extProp>()
}
private /* final field */ val $$delegate_0: IFoo = foo
}
class DefaultImpl : IFoo {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
}
class ExplicitOverride : IFoo {
constructor() /* primary */ {
super/*Any*/()
/* <init>() */
}
override val prop: String
override get(): String {
return ""
}
override val String.extProp: String
override get(): String {
return ""
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface IFoo {
@Deprecated("")
val prop: String get() = ""
@@ -1,37 +0,0 @@
FILE fqName:<root> fileName:/typeAliasesWithAnnotations.kt
TYPEALIAS name:TestTypeAlias visibility:public expandedType:kotlin.String
annotations:
TestAnn(x = 'TestTypeAlias')
CLASS ANNOTATION_CLASS name:TestAnn modality:OPEN visibility:public superTypes:[kotlin.Annotation]
annotations:
Target(allowedTargets = [GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:TYPEALIAS' type=kotlin.annotation.AnnotationTarget])
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestAnn
CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:<root>.TestAnn [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:TestAnn modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: kotlin.String declared in <root>.TestAnn.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.TestAnn) returnType:kotlin.String
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.TestAnn
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): kotlin.String declared in <root>.TestAnn'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.TestAnn declared in <root>.TestAnn.<get-x>' type=<root>.TestAnn 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.Annotation
$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.Annotation
$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.Annotation
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -1,15 +0,0 @@
@TestAnn(x = "TestTypeAlias")
typealias TestTypeAlias = String
@Target(allowedTargets = [AnnotationTarget.TYPEALIAS])
open annotation class TestAnn : Annotation {
constructor(x: String) /* primary */ {
super/*Any*/()
/* <init>() */
}
val x: String
field = x
get
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
@Target(AnnotationTarget.TYPEALIAS)
annotation class TestAnn(val x: String)