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
@@ -142,7 +142,7 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
BLOCK_BODY
CALL 'public abstract fun foo <B> (a: A of <root>.IBase, b: B of <root>.IBase.foo): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<B>: B of <root>.Test2.foo
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.foo' type=<root>.Test2 origin=null
a: GET_VAR 'a: kotlin.String declared in <root>.Test2.foo' type=kotlin.String origin=null
b: GET_VAR 'b: B of <root>.Test2.foo declared in <root>.Test2.foo' type=B of <root>.Test2.foo origin=null
@@ -160,7 +160,7 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
RETURN type=kotlin.Nothing from='public open fun <get-id> <C> (): kotlin.collections.Map<kotlin.String, C of <root>.Test2.<get-id>>? declared in <root>.Test2'
CALL 'public abstract fun <get-id> <C> (): kotlin.collections.Map<A of <root>.IBase, C of <root>.IBase.<get-id>>? declared in <root>.IBase' type=kotlin.collections.Map<kotlin.String, C of <root>.Test2.<get-id>>? origin=null
<C>: C of <root>.Test2.<get-id>
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-id>' type=<root>.Test2 origin=null
$receiver: GET_VAR '<this>: C of <root>.Test2.<get-id> declared in <root>.Test2.<get-id>' type=C of <root>.Test2.<get-id> origin=null
PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var]
@@ -177,7 +177,7 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
RETURN type=kotlin.Nothing from='public open fun <get-x> <D> (): D of <root>.Test2.<get-x>? declared in <root>.Test2'
CALL 'public abstract fun <get-x> <D> (): D of <root>.IBase.<get-x>? declared in <root>.IBase' type=D of <root>.Test2.<get-x>? origin=null
<D>: D of <root>.Test2.<get-x>
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-x>' type=<root>.Test2 origin=null
$receiver: GET_VAR '<this>: kotlin.collections.List<D of <root>.Test2.<get-x>> declared in <root>.Test2.<get-x>' type=kotlin.collections.List<D of <root>.Test2.<get-x>> origin=null
FUN DELEGATED_MEMBER name:<set-x> visibility:public modality:OPEN <D> ($this:<root>.Test2, $receiver:kotlin.collections.List<D of <root>.Test2.<get-x>>, <set-?>:D of <root>.Test2.<set-x>?) returnType:kotlin.Unit
@@ -191,13 +191,10 @@ FILE fqName:<root> fileName:/delegatedGenericImplementation.kt
BLOCK_BODY
CALL 'public abstract fun <set-x> <D> (<set-?>: D of <root>.IBase.<set-x>?): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
<D>: D of <root>.Test2.<set-x>
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<kotlin.String> visibility:local [final]' type=<root>.IBase<kotlin.String> origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private' type=<root>.IBase<kotlin.String> origin=null
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-x>' type=<root>.Test2 origin=null
$receiver: GET_VAR '<this>: kotlin.collections.List<D of <root>.Test2.<get-x>> declared in <root>.Test2.<set-x>' type=kotlin.collections.List<D of <root>.Test2.<get-x>> origin=null
<set-?>: GET_VAR '<set-?>: D of <root>.Test2.<set-x>? declared in <root>.Test2.<set-x>' type=D of <root>.Test2.<set-x>? origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<kotlin.String> visibility:local [final]
EXPRESSION_BODY
GET_VAR 'j: <root>.IBase<kotlin.String> declared in <root>.Test2.<init>' type=<root>.IBase<kotlin.String> origin=null
PROPERTY name:j visibility:public modality:FINAL [var]
FIELD PROPERTY_BACKING_FIELD name:j type:<root>.IBase<kotlin.String> visibility:private
EXPRESSION_BODY
@@ -45,23 +45,22 @@ class Test2 : IBase<String> {
}
override fun <B : Any?> foo(a: String, b: B) {
<this>.#<$$delegate_0>.foo<B>(a = a, b = b)
<this>.#j.foo<B>(a = a, b = b)
}
override val <C : Any?> C.id: Map<String, C>?
override get(): Map<String, C>? {
return (<this>.#<$$delegate_0>, <this>).<get-id><C>()
return (<this>.#j, <this>).<get-id><C>()
}
override var <D : Any?> List<D>.x: D?
override get(): D? {
return (<this>.#<$$delegate_0>, <this>).<get-x><D>()
return (<this>.#j, <this>).<get-x><D>()
}
override set(<set-?>: D?) {
(<this>.#<$$delegate_0>, <this>).<set-x><D>(<set-?> = <set-?>)
(<this>.#j, <this>).<set-x><D>(<set-?> = <set-?>)
}
local /* final field */ val <$$delegate_0>: IBase<String> = j
var j: IBase<String>
field = j
get
@@ -13,7 +13,7 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
VALUE_PARAMETER name:x index:0 type:@[EnhancedNullability] kotlin.String
BLOCK_BODY
CALL 'public abstract fun takeNotNull (x: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeNotNull' type=<root>.Test origin=null
x: GET_VAR 'x: @[EnhancedNullability] kotlin.String declared in <root>.Test.takeNotNull' type=@[EnhancedNullability] kotlin.String origin=null
FUN DELEGATED_MEMBER name:takeNullable visibility:public modality:OPEN <> ($this:<root>.Test, x:kotlin.String?) returnType:kotlin.Unit
@@ -23,7 +23,7 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
VALUE_PARAMETER name:x index:0 type:kotlin.String?
BLOCK_BODY
CALL 'public abstract fun takeNullable (x: kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeNullable' type=<root>.Test origin=null
x: GET_VAR 'x: kotlin.String? declared in <root>.Test.takeNullable' type=kotlin.String? origin=null
FUN DELEGATED_MEMBER name:takeFlexible visibility:public modality:OPEN <> ($this:<root>.Test, x:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Unit
@@ -33,7 +33,7 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
VALUE_PARAMETER name:x index:0 type:@[FlexibleNullability] kotlin.String?
BLOCK_BODY
CALL 'public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.takeFlexible' type=<root>.Test origin=null
x: GET_VAR 'x: @[FlexibleNullability] kotlin.String? declared in <root>.Test.takeFlexible' type=@[FlexibleNullability] kotlin.String? origin=null
FUN DELEGATED_MEMBER name:returnNotNull visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[EnhancedNullability] kotlin.String
@@ -46,7 +46,7 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
RETURN type=kotlin.Nothing from='public open fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.Test'
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNotNull' type=<root>.Test origin=null
FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:<root>.Test) returnType:kotlin.String?
annotations:
@@ -57,7 +57,7 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnNullable (): kotlin.String? declared in <root>.Test'
CALL 'public abstract fun returnNullable (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnNullable' type=<root>.Test origin=null
FUN DELEGATED_MEMBER name:returnsFlexible visibility:public modality:OPEN <> ($this:<root>.Test) returnType:@[FlexibleNullability] kotlin.String?
overridden:
@@ -66,11 +66,8 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in <root>.Test'
CALL 'public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=<root>.J origin=null
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]' type=<root>.J origin=null
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.returnsFlexible' type=<root>.Test origin=null
FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]
EXPRESSION_BODY
GET_VAR 'j: <root>.J declared in <root>.Test.<init>' type=<root>.J origin=null
PROPERTY name:j visibility:private modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:j type:<root>.J visibility:private [final]
EXPRESSION_BODY
@@ -6,32 +6,31 @@ class Test : J {
}
override fun takeNotNull(x: @EnhancedNullability String) {
<this>.#<$$delegate_0>.takeNotNull(x = x)
<this>.#j.takeNotNull(x = x)
}
override fun takeNullable(x: String?) {
<this>.#<$$delegate_0>.takeNullable(x = x)
<this>.#j.takeNullable(x = x)
}
override fun takeFlexible(x: @FlexibleNullability String?) {
<this>.#<$$delegate_0>.takeFlexible(x = x)
<this>.#j.takeFlexible(x = x)
}
@NotNull
override fun returnNotNull(): @EnhancedNullability String {
return <this>.#<$$delegate_0>.returnNotNull() /*!! String */
return <this>.#j.returnNotNull() /*!! String */
}
@Nullable
override fun returnNullable(): String? {
return <this>.#<$$delegate_0>.returnNullable()
return <this>.#j.returnNullable()
}
override fun returnsFlexible(): @FlexibleNullability String? {
return <this>.#<$$delegate_0>.returnsFlexible()
return <this>.#j.returnsFlexible()
}
local /* final field */ val <$$delegate_0>: J = j
private val j: J
field = j
private get