JS: refactor code that copies default methods in interfaces to classes
Als fixes KT-21245
This commit is contained in:
+32
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user