Implementing interface by delegation: creating delegates in class.

This commit is contained in:
Dmitry Petrov
2016-09-01 19:08:37 +03:00
committed by Dmitry Petrov
parent 264c8afc78
commit 2438876173
6 changed files with 105 additions and 11 deletions
@@ -0,0 +1,9 @@
interface IBase
object BaseImpl : IBase
interface IOther
fun otherImpl(): IOther = object : IOther {}
class Test1 : IBase by BaseImpl
class Test2 : IBase by BaseImpl, IOther by otherImpl()
@@ -0,0 +1,33 @@
FILE /delegatedImplementation.kt
CLASS INTERFACE IBase
CLASS OBJECT BaseImpl
CONSTRUCTOR private constructor BaseImpl()
BLOCK_BODY
INSTANCE_INITIALIZER_CALL classDescriptor=BaseImpl
CLASS INTERFACE IOther
FUN public fun otherImpl(): IOther
BLOCK_BODY
RETURN type=kotlin.Nothing from=otherImpl
BLOCK type=otherImpl.<no name provided> operator=OBJECT_LITERAL
CLASS CLASS <no name provided>
CONSTRUCTOR public constructor <no name provided>()
BLOCK_BODY
INSTANCE_INITIALIZER_CALL classDescriptor=<no name provided>
CALL .<init> type=otherImpl.<no name provided> operator=OBJECT_LITERAL
CLASS CLASS Test1
CONSTRUCTOR public constructor Test1()
BLOCK_BODY
INSTANCE_INITIALIZER_CALL classDescriptor=Test1
DELEGATE val `Test1$IBase$delegate`: BaseImpl
EXPRESSION_BODY
GET_OBJECT BaseImpl type=BaseImpl
CLASS CLASS Test2
CONSTRUCTOR public constructor Test2()
BLOCK_BODY
INSTANCE_INITIALIZER_CALL classDescriptor=Test2
DELEGATE val `Test2$IBase$delegate`: BaseImpl
EXPRESSION_BODY
GET_OBJECT BaseImpl type=BaseImpl
DELEGATE val `Test2$IOther$delegate`: IOther
EXPRESSION_BODY
CALL .otherImpl type=IOther operator=null