Tests:ObjectInheritingFromATrait test enhanced, ObjectInheritingFromClass test added.
This commit is contained in:
@@ -53,4 +53,7 @@ public final class ObjectTest extends SingleFileTranslationTest {
|
|||||||
fooBoxTest();
|
fooBoxTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testObjectInheritingFromClass() throws Exception {
|
||||||
|
fooBoxTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fun f() : Boolean
|
fun execute(handler: ()->Unit) {
|
||||||
|
execute(false, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun execute(onlyIfAttached: Boolean, handler: ()->Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
object foo : Foo {
|
object foo : Foo {
|
||||||
override fun f() = true
|
override fun execute(onlyIfAttached: Boolean, handler: ()->Unit) {
|
||||||
|
handler()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box() : Boolean {
|
private var result = false
|
||||||
return foo.f()
|
|
||||||
|
fun box(): Boolean {
|
||||||
|
foo.execute() {
|
||||||
|
result = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
abstract class A(val s:String) {
|
||||||
|
}
|
||||||
|
|
||||||
|
object B : A("test") {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = B.s == "test"
|
||||||
Reference in New Issue
Block a user