Test for delegated members being overridden

This commit is contained in:
Pavel V. Talanov
2013-09-17 21:28:34 +04:00
parent 51a6bcb727
commit 9599f7d98c
2 changed files with 54 additions and 0 deletions
@@ -0,0 +1,49 @@
package test
trait X {
fun foo(): String? {
return null
}
}
trait Y {
fun foo(): String {
return "foo"
}
}
trait Incompatible {
fun foo(): Int {
return 3
}
}
class Test1(val x: X) : X by x, Y {
override fun foo(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>String?<!> {
return null
}
}
class Test2(val x: X) : X by x, Y {
override fun foo(): String {
return "foo"
}
}
class Test3(val y: Y) : X, Y by y {
override fun foo(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>String?<!> {
return null
}
}
class Test4(val y: Y) : X, Y by y {
override fun foo(): String {
return "foo"
}
}
class Test5(val y: Y, val x: X) : X by x, Y by y, Incompatible {
override fun foo(): <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!> {
return 3
}
}
@@ -4350,6 +4350,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/override/DefaultParameterValues-NoErrorsWhenInheritingFromOneTypeTwice.kt");
}
@TestMetadata("Delegation.kt")
public void testDelegation() throws Exception {
doTest("compiler/testData/diagnostics/tests/override/Delegation.kt");
}
@TestMetadata("DelegationFun.kt")
public void testDelegationFun() throws Exception {
doTest("compiler/testData/diagnostics/tests/override/DelegationFun.kt");