Assertions when approximating platform types in delegation by expression

This commit is contained in:
Andrey Breslav
2014-10-05 22:19:30 +04:00
parent f1c66fa6b0
commit a737352b5d
9 changed files with 151 additions and 50 deletions
@@ -0,0 +1,7 @@
public class Delegation {
public static class ReturnNull {
public String foo() {
return null;
}
}
}
@@ -0,0 +1,21 @@
trait Tr {
fun foo(): String
}
class DelegateTo : Delegation.ReturnNull(), Tr {
override fun foo() = super<Delegation.ReturnNull>.foo()
}
class DelegateFrom : Tr by DelegateTo() {
}
fun box(): String {
try {
DelegateFrom().foo()
return "Fail: should have been an exception"
}
catch(e: IllegalStateException) {
println(e.getMessage())
return "OK"
}
}