Fix concrete method inheritance in interfaces
For each non-abstract non-declared (i.e. inherited from supertypes) method in an interface we generate its static form to the TImpl, which calls the TImpl method from the corresponding supertype. The accidental override tests changed because we're now trying to generate the delegate for the super method, not knowing that it will clash with the declared method #KT-2888 Fixed #KT-5393 Fixed
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
interface A {
|
||||
fun foo(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
interface B : A
|
||||
|
||||
class C : B {
|
||||
override fun foo(): String {
|
||||
return super.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return C().foo()
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
var result = "Fail"
|
||||
|
||||
interface A {
|
||||
var foo: String
|
||||
get() = result
|
||||
set(value) { result = value }
|
||||
}
|
||||
|
||||
interface B : A
|
||||
|
||||
class C : B {
|
||||
override var foo: String
|
||||
get() = super.foo
|
||||
set(value) { super.foo = value }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
C().foo = "OK"
|
||||
return C().foo
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
interface A {
|
||||
override fun toString(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
interface B : A
|
||||
|
||||
class C : B {
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = "${C()}"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
interface A {
|
||||
fun foo(): Number {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
interface B : A
|
||||
|
||||
class C : B {
|
||||
override fun foo(): Int {
|
||||
return super.foo() as Int
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = C().foo()
|
||||
return if (x == 42) "OK" else "Fail: $x"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
interface A {
|
||||
fun foo() = "Fail"
|
||||
}
|
||||
|
||||
interface B : A
|
||||
|
||||
interface C : A {
|
||||
override fun foo() = "OK"
|
||||
}
|
||||
|
||||
interface D : B, C
|
||||
|
||||
class Impl : D
|
||||
|
||||
fun box(): String = Impl().foo()
|
||||
@@ -0,0 +1,18 @@
|
||||
interface A<T, U : Number, V : Any> {
|
||||
fun foo(t: T, u: U): V? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
interface B<T, V : Any> : A<T, Int, V>
|
||||
|
||||
class C : B<String, Runnable> {
|
||||
override fun foo(t: String, u: Int): Runnable? {
|
||||
return super.foo(t, u)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val x = C().foo("", 0)
|
||||
return if (x == null) "OK" else "Fail: $x"
|
||||
}
|
||||
Reference in New Issue
Block a user