FIR2IR: don't create separate delegate fields for constructor properties

This commit is contained in:
Mikhail Glukhikh
2021-12-07 10:41:57 +03:00
parent f8b3eb0801
commit 386e2e0950
12 changed files with 80 additions and 74 deletions
@@ -127,7 +127,7 @@ FILE fqName:<root> fileName:/Fir2IrClassifierStorage.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-session> (): <root>.FirSession declared in <root>.Fir2IrClassifierStorage'
CALL 'public abstract fun <get-session> (): <root>.FirSession declared in <root>.Fir2IrComponents' type=<root>.FirSession origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.Fir2IrComponents visibility:local [final]' type=<root>.Fir2IrComponents origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:components type:<root>.Fir2IrComponents visibility:private [final]' type=<root>.Fir2IrComponents origin=null
receiver: GET_VAR '<this>: <root>.Fir2IrClassifierStorage declared in <root>.Fir2IrClassifierStorage.<get-session>' type=<root>.Fir2IrClassifierStorage origin=null
PROPERTY DELEGATED_MEMBER name:classifierStorage visibility:public modality:OPEN [val]
overridden:
@@ -140,11 +140,8 @@ FILE fqName:<root> fileName:/Fir2IrClassifierStorage.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-classifierStorage> (): <root>.Fir2IrClassifierStorage declared in <root>.Fir2IrClassifierStorage'
CALL 'public abstract fun <get-classifierStorage> (): <root>.Fir2IrClassifierStorage declared in <root>.Fir2IrComponents' type=<root>.Fir2IrClassifierStorage origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.Fir2IrComponents visibility:local [final]' type=<root>.Fir2IrComponents origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:components type:<root>.Fir2IrComponents visibility:private [final]' type=<root>.Fir2IrComponents origin=null
receiver: GET_VAR '<this>: <root>.Fir2IrClassifierStorage declared in <root>.Fir2IrClassifierStorage.<get-classifierStorage>' type=<root>.Fir2IrClassifierStorage origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.Fir2IrComponents visibility:local [final]
EXPRESSION_BODY
GET_VAR 'components: <root>.Fir2IrComponents declared in <root>.Fir2IrClassifierStorage.<init>' type=<root>.Fir2IrComponents origin=null
PROPERTY name:components visibility:private modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:components type:<root>.Fir2IrComponents visibility:private [final]
EXPRESSION_BODY
@@ -46,15 +46,14 @@ class Fir2IrClassifierStorage : Fir2IrComponents {
override val session: FirSession
override get(): FirSession {
return <this>.#<$$delegate_0>.<get-session>()
return <this>.#components.<get-session>()
}
override val classifierStorage: Fir2IrClassifierStorage
override get(): Fir2IrClassifierStorage {
return <this>.#<$$delegate_0>.<get-classifierStorage>()
return <this>.#components.<get-classifierStorage>()
}
local /* final field */ val <$$delegate_0>: Fir2IrComponents = components
private val components: Fir2IrComponents
field = components
private get
@@ -96,11 +96,8 @@ FILE fqName:<root> fileName:/SignatureClash.kt
$this: VALUE_PARAMETER name:<this> type:<root>.DataClass
BLOCK_BODY
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.Delegate' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.Delegate visibility:local [final]' type=<root>.Delegate origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegate type:<root>.Delegate visibility:private [final]' type=<root>.Delegate origin=null
receiver: GET_VAR '<this>: <root>.DataClass declared in <root>.DataClass.bar' type=<root>.DataClass origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.Delegate visibility:local [final]
EXPRESSION_BODY
GET_VAR 'delegate: <root>.Delegate declared in <root>.DataClass.<init>' type=<root>.Delegate origin=null
PROPERTY name:delegate visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:delegate type:<root>.Delegate visibility:private [final]
EXPRESSION_BODY
@@ -37,10 +37,9 @@ data class DataClass : Derived, Delegate {
}
override fun bar() {
<this>.#<$$delegate_0>.bar()
<this>.#delegate.bar()
}
local /* final field */ val <$$delegate_0>: Delegate = delegate
val delegate: Delegate
field = delegate
get
+8 -11
View File
@@ -16,7 +16,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun containsKey (key: K of <root>.ControlFlowInfo): kotlin.Boolean declared in <root>.ControlFlowInfo'
CALL 'public abstract fun containsKey (key: K of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.containsKey' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
key: GET_VAR 'key: K of <root>.ControlFlowInfo declared in <root>.ControlFlowInfo.containsKey' type=K of <root>.ControlFlowInfo origin=null
FUN DELEGATED_MEMBER name:containsValue visibility:public modality:OPEN <> ($this:<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo>, value:V of <root>.ControlFlowInfo) returnType:kotlin.Boolean
@@ -27,7 +27,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun containsValue (value: V of <root>.ControlFlowInfo): kotlin.Boolean declared in <root>.ControlFlowInfo'
CALL 'public abstract fun containsValue (value: V of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.containsValue' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
value: GET_VAR 'value: V of <root>.ControlFlowInfo declared in <root>.ControlFlowInfo.containsValue' type=V of <root>.ControlFlowInfo origin=null
FUN DELEGATED_MEMBER name:get visibility:public modality:OPEN <> ($this:<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo>, key:K of <root>.ControlFlowInfo) returnType:V of <root>.ControlFlowInfo? [operator]
@@ -38,7 +38,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun get (key: K of <root>.ControlFlowInfo): V of <root>.ControlFlowInfo? [operator] declared in <root>.ControlFlowInfo'
CALL 'public abstract fun get (key: K of kotlin.collections.Map): V of kotlin.collections.Map? [operator] declared in kotlin.collections.Map' type=V of <root>.ControlFlowInfo? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.get' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
key: GET_VAR 'key: K of <root>.ControlFlowInfo declared in <root>.ControlFlowInfo.get' type=K of <root>.ControlFlowInfo origin=null
FUN DELEGATED_MEMBER name:isEmpty visibility:public modality:OPEN <> ($this:<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo>) returnType:kotlin.Boolean
@@ -48,7 +48,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in <root>.ControlFlowInfo'
CALL 'public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.isEmpty' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
PROPERTY DELEGATED_MEMBER name:entries visibility:public modality:OPEN [val]
overridden:
@@ -61,7 +61,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-entries> (): kotlin.collections.Set<kotlin.collections.Map.Entry<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo>> declared in <root>.ControlFlowInfo'
CALL 'public abstract fun <get-entries> (): kotlin.collections.Set<kotlin.collections.Map.Entry<K of kotlin.collections.Map, V of kotlin.collections.Map>> declared in kotlin.collections.Map' type=kotlin.collections.Set<kotlin.collections.Map.Entry<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo>> origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.<get-entries>' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
PROPERTY DELEGATED_MEMBER name:keys visibility:public modality:OPEN [val]
overridden:
@@ -74,7 +74,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-keys> (): kotlin.collections.Set<K of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo'
CALL 'public abstract fun <get-keys> (): kotlin.collections.Set<K of kotlin.collections.Map> declared in kotlin.collections.Map' type=kotlin.collections.Set<K of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.<get-keys>' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val]
overridden:
@@ -87,7 +87,7 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-size> (): kotlin.Int declared in <root>.ControlFlowInfo'
CALL 'public abstract fun <get-size> (): kotlin.Int declared in kotlin.collections.Map' type=kotlin.Int origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.<get-size>' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
PROPERTY DELEGATED_MEMBER name:values visibility:public modality:OPEN [val]
overridden:
@@ -100,11 +100,8 @@ FILE fqName:<root> fileName:/kt43342.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun <get-values> (): kotlin.collections.Collection<V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo'
CALL 'public abstract fun <get-values> (): kotlin.collections.Collection<V of kotlin.collections.Map> declared in kotlin.collections.Map' type=kotlin.collections.Collection<V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
receiver: GET_VAR '<this>: <root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.<get-values>' type=<root>.ControlFlowInfo<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:local [final]
EXPRESSION_BODY
GET_VAR 'map: kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> declared in <root>.ControlFlowInfo.<init>' type=kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> origin=null
PROPERTY name:map visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map<K of <root>.ControlFlowInfo, V of <root>.ControlFlowInfo> visibility:private [final]
EXPRESSION_BODY
+8 -9
View File
@@ -6,42 +6,41 @@ open class ControlFlowInfo<K : Any?, V : Any?> : Map<K, V> {
}
override fun containsKey(key: K): Boolean {
return <this>.#<$$delegate_0>.containsKey(key = key)
return <this>.#map.containsKey(key = key)
}
override fun containsValue(value: V): Boolean {
return <this>.#<$$delegate_0>.containsValue(value = value)
return <this>.#map.containsValue(value = value)
}
override operator fun get(key: K): V? {
return <this>.#<$$delegate_0>.get(key = key)
return <this>.#map.get(key = key)
}
override fun isEmpty(): Boolean {
return <this>.#<$$delegate_0>.isEmpty()
return <this>.#map.isEmpty()
}
override val entries: Set<Entry<K, V>>
override get(): Set<Entry<K, V>> {
return <this>.#<$$delegate_0>.<get-entries>()
return <this>.#map.<get-entries>()
}
override val keys: Set<K>
override get(): Set<K> {
return <this>.#<$$delegate_0>.<get-keys>()
return <this>.#map.<get-keys>()
}
override val size: Int
override get(): Int {
return <this>.#<$$delegate_0>.<get-size>()
return <this>.#map.<get-size>()
}
override val values: Collection<V>
override get(): Collection<V> {
return <this>.#<$$delegate_0>.<get-values>()
return <this>.#map.<get-values>()
}
local /* final field */ val <$$delegate_0>: Map<K, V> = map
val map: Map<K, V>
field = map
get