generate CHECK_CAST for smartcasted 'this'
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user