[FIR] add support for implementation by delgation
This commit handles "subclass: super-interface by delegate-expression". During Psi2Fir, for each delegate, we add to the subclass a synthetic field (which has type super-interface), and an assignment of the delegate-expression to the synthetic field in the primary constructor, so that the delegate-expression can be resolved and transformed along the way. During Fir2Ir, we look up delegatable members from the super-interface and generate corresponding functions/properties for the subclass. TODO: support for generic delegatable members and generic super-interface.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1d45dc8d81
commit
d163853c97
+10
-2
@@ -53,15 +53,23 @@ FILE fqName:<root> fileName:/delegatedImplementationWithExplicitOverride.kt
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.IFooBar]'
|
||||
SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]' type=kotlin.Unit origin=EQ
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C origin=null
|
||||
value: GET_OBJECT 'CLASS OBJECT name:FooBarImpl modality:FINAL visibility:public superTypes:[<root>.IFooBar]' type=<root>.FooBarImpl
|
||||
FUN name:bar visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun bar (): kotlin.Unit declared in <root>.IFooBar
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFooBar) returnType:kotlin.Unit [fake_override]
|
||||
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.C) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun foo (): kotlin.Unit declared in <root>.IFooBar
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IFooBar
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.IFooBar' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]' type=<root>.IFooBar origin=null
|
||||
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.foo' type=<root>.C origin=null
|
||||
FIELD DELEGATE name:$$delegate_0 type:<root>.IFooBar visibility:local [final]
|
||||
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