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
|
||||
|
||||
@@ -11,7 +11,6 @@ class A : I {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
<this>.#<$$delegate_0> = i
|
||||
}
|
||||
|
||||
override val <T : Any?> T.id: T
|
||||
@@ -19,7 +18,7 @@ class A : I {
|
||||
return (<this>.#<$$delegate_0>, <this>).<get-id></* null */>()
|
||||
}
|
||||
|
||||
local /* final field */ val <$$delegate_0>: I
|
||||
local /* final field */ val <$$delegate_0>: I = i
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,6 @@ FILE fqName:<root> fileName:/kt35550.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[<root>.I]'
|
||||
SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.I visibility:local [final]' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
value: GET_VAR 'i: <root>.I declared in <root>.A.<init>' type=<root>.I origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
|
||||
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <T> ($this:<root>.A, $receiver:T of <root>.A.<get-id>) returnType:T of <root>.A.<get-id>
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
|
||||
@@ -49,6 +46,8 @@ FILE fqName:<root> fileName:/kt35550.kt
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-id>' type=<root>.A origin=null
|
||||
$receiver: GET_VAR '<this>: T of <root>.A.<get-id> declared in <root>.A.<get-id>' type=T of <root>.A.<get-id> origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.I visibility:local [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'i: <root>.I declared in <root>.A.<init>' type=<root>.I 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
@@ -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