FIR: introduce delegate field initializers

Before this commit we initialized delegate fields in primary constructor,
that could provoke NPE in case delegate is used in initializer of
some property backing field.
Now we initialize delegate fields directly instead.
This commit is contained in:
Mikhail Glukhikh
2021-02-02 17:51:11 +03:00
parent 2cbdad0bb1
commit d4b0688690
69 changed files with 928 additions and 356 deletions
@@ -6,20 +6,6 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.J]'
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [final]' type=kotlin.Unit origin=EQ
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test origin=null
value: 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
GET_VAR 'j: <root>.J declared in <root>.Test.<init>' type=<root>.J origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-j> visibility:private modality:FINAL <> ($this:<root>.Test) returnType:<root>.J
correspondingProperty: PROPERTY name:j visibility:private modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test
BLOCK_BODY
RETURN type=kotlin.Nothing from='private final fun <get-j> (): <root>.J declared in <root>.Test'
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.<get-j>' type=<root>.Test origin=null
FUN DELEGATED_MEMBER name:takeNotNull visibility:public modality:OPEN <> ($this:<root>.Test, x:@[EnhancedNullability] kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun takeNotNull (x: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.J
@@ -82,6 +68,19 @@ FILE fqName:<root> fileName:/delegatedImplementationOfJavaInterface.kt
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.J visibility:local [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
GET_VAR 'j: <root>.J declared in <root>.Test.<init>' type=<root>.J origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-j> visibility:private modality:FINAL <> ($this:<root>.Test) returnType:<root>.J
correspondingProperty: PROPERTY name:j visibility:private modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test
BLOCK_BODY
RETURN type=kotlin.Nothing from='private final fun <get-j> (): <root>.J declared in <root>.Test'
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.<get-j>' type=<root>.Test 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 [operator] declared in kotlin.Any