JS/RTTI: added another cast to reified test

This commit is contained in:
Alexey Tsvetkov
2015-06-24 17:52:14 +03:00
committed by Alexey Andreev
parent a9d5c74ff7
commit f7af868d4f
3 changed files with 28 additions and 3 deletions
@@ -0,0 +1,19 @@
package foo
interface A
class AImpl : A {}
inline
fun test<reified T>(x: Any?): T? = x as T?
fun box(): String {
var a: A? = AImpl()
assertEquals(a, test<A>(a), "a = AImpl()")
a = object : A {}
assertEquals(a, test<A>(a), "a = object : A{}")
assertEquals(null, test<A>(null), "test(null)")
failsClassCast("test(object{})") { test<A>(object{}) }
return "OK"
}