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:
+1
-2
@@ -12,7 +12,6 @@ class Test<TT : Any?> : IBase<TT> {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
<this>.#<$$delegate_0> = impl
|
||||
}
|
||||
|
||||
override fun foo(x: Int) {
|
||||
@@ -28,7 +27,7 @@ class Test<TT : Any?> : IBase<TT> {
|
||||
return <this>.#<$$delegate_0>.<get-bar>()
|
||||
}
|
||||
|
||||
local /* final field */ val <$$delegate_0>: IBase<TT>
|
||||
local /* final field */ val <$$delegate_0>: IBase<TT> = impl
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -35,9 +35,6 @@ FILE fqName:<root> fileName:/delegatedMembers.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>.IBase<TT of <root>.Test>]'
|
||||
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test' type=<root>.Test<TT of <root>.Test> origin=null
|
||||
value: GET_VAR 'impl: <root>.IBase<TT of <root>.Test> declared in <root>.Test.<init>' type=<root>.IBase<TT of <root>.Test> origin=null
|
||||
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Test<TT of <root>.Test>, x:kotlin.Int) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in <root>.IBase
|
||||
@@ -74,6 +71,8 @@ FILE fqName:<root> fileName:/delegatedMembers.kt
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<TT of <root>.Test> visibility:local [final]' type=<root>.IBase<TT of <root>.Test> origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test<TT of <root>.Test> declared in <root>.Test.<get-bar>' type=<root>.Test<TT of <root>.Test> origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase<TT of <root>.Test> visibility:local [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'impl: <root>.IBase<TT of <root>.Test> declared in <root>.Test.<init>' type=<root>.IBase<TT of <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
|
||||
|
||||
Reference in New Issue
Block a user