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:
Vendored
+1
-2
@@ -24,7 +24,6 @@ class DFoo : IFoo {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
<this>.#<$$delegate_0> = d
|
||||
}
|
||||
|
||||
@Ann
|
||||
@@ -49,7 +48,7 @@ class DFoo : IFoo {
|
||||
return (<this>.#<$$delegate_0>, <this>).<get-testExtVal>()
|
||||
}
|
||||
|
||||
local /* final field */ val <$$delegate_0>: IFoo
|
||||
local /* final field */ val <$$delegate_0>: IFoo = d
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -59,9 +59,6 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DFoo modality:FINAL visibility:public superTypes:[<root>.IFoo]'
|
||||
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.DFoo declared in <root>.DFoo' type=<root>.DFoo origin=null
|
||||
value: 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
|
||||
@@ -113,6 +110,8 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
|
||||
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:local [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 [operator] declared in kotlin.Any
|
||||
|
||||
+1
-2
@@ -18,7 +18,6 @@ class Delegated : IFoo {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
<this>.#<$$delegate_0> = foo
|
||||
}
|
||||
|
||||
@Deprecated(message = "")
|
||||
@@ -33,7 +32,7 @@ class Delegated : IFoo {
|
||||
return (<this>.#<$$delegate_0>, <this>).<get-extProp>()
|
||||
}
|
||||
|
||||
local /* final field */ val <$$delegate_0>: IFoo
|
||||
local /* final field */ val <$$delegate_0>: IFoo = foo
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -40,9 +40,6 @@ FILE fqName:<root> fileName:/inheritingDeprecation.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]'
|
||||
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated' type=<root>.Delegated origin=null
|
||||
value: GET_VAR 'foo: <root>.IFoo declared in <root>.Delegated.<init>' type=<root>.IFoo origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:prop visibility:public modality:OPEN [val]
|
||||
annotations:
|
||||
Deprecated(message = '', replaceWith = <null>, level = <null>)
|
||||
@@ -72,6 +69,8 @@ FILE fqName:<root> fileName:/inheritingDeprecation.kt
|
||||
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:local [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 [operator] declared in kotlin.Any
|
||||
|
||||
Reference in New Issue
Block a user