generate CHECK_CAST for smartcasted 'this'

This commit is contained in:
Svetlana Isakova
2014-01-21 13:37:36 +04:00
parent 9ed57a5767
commit 9d493b6f7b
5 changed files with 43 additions and 8 deletions
@@ -0,0 +1,13 @@
open class A
class B : A() {
fun foo(i: Int) = i
}
fun A.test() = if (this is B) foo(42) else 0
fun box(): String {
if (B().test() != 42) return "fail1"
if (A().test() != 0) return "fail2"
return "OK"
}
@@ -0,0 +1,11 @@
package h
open class A {
fun bar() = if (this is B) this.foo() else "fail"
}
class B() : A() {
fun foo() = "OK"
}
fun box() = B().bar()