JS: refactor code that copies default methods in interfaces to classes

Als fixes KT-21245
This commit is contained in:
Alexey Andreev
2017-11-14 17:03:05 +03:00
parent 38e50e964a
commit 32a0221474
6 changed files with 119 additions and 81 deletions
@@ -0,0 +1,32 @@
// EXPECTED_REACHABLE_NODES: 1147
interface I {
fun foo(x: String = "default"): String = "I.foo($x)"
}
interface J : I {
override fun foo(x: String): String
}
interface K : J {
override fun foo(x: String): String = "K.foo($x)"
}
class A : I
class B : K
fun box(): String {
val a = A()
var r = a.foo()
if (r != "I.foo(default)") return "fail: A.foo()"
r = a.foo("Q")
if (r != "I.foo(Q)") return "fail A.foo(Q): $r"
val b = B()
r = b.foo()
if (r != "K.foo(default)") return "fail B.foo(): $r"
r = b.foo("W")
if (r != "K.foo(W)") return "fail B.foo(W): $r"
return "OK"
}