More tests on casts on receiver of inline class type

This commit is contained in:
Dmitry Petrov
2018-09-24 10:46:10 +03:00
parent 88cc900dc7
commit c1bb3479df
10 changed files with 154 additions and 100 deletions
@@ -0,0 +1,29 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
interface IBase {
fun testDefault1() = if (this is B) this.foo() else "fail"
}
interface IFoo : IBase {
fun foo(): String
fun testDefault2() = if (this is B) this.foo() else "fail"
}
inline class B(val x: String) : IFoo {
override fun foo() = x
}
fun IBase.test1() = if (this is IFoo) foo() else "fail"
fun IBase.test2() = if (this is B) foo() else "fail"
fun box(): String {
if (B("OK").test1() != "OK") throw AssertionError()
if (B("OK").test2() != "OK") throw AssertionError()
if (B("OK").testDefault1() != "OK") throw AssertionError()
if (B("OK").testDefault2() != "OK") throw AssertionError()
return "OK"
}