JS/RTTI. Fix build and tests
This commit is contained in:
committed by
Alexey Andreev
parent
9bb60b48b2
commit
3a87049359
+4
-4
@@ -4,13 +4,13 @@ open class A
|
||||
class B : A()
|
||||
class C
|
||||
|
||||
fun notNullToNotNullT<T : A>(a: Any): T = a as T
|
||||
fun <T : A> notNullToNotNullT(a: Any): T = a as T
|
||||
|
||||
fun nullableToNotNullT<T : A>(a: Any?): T = a as T
|
||||
fun <T : A> nullableToNotNullT(a: Any?): T = a as T
|
||||
|
||||
fun notNullToNullableT<T : A>(a: Any): T? = a as T?
|
||||
fun <T : A> notNullToNullableT(a: Any): T? = a as T?
|
||||
|
||||
fun nullableToNullableT<T : A>(a: Any?): T? = a as T?
|
||||
fun <T : A> nullableToNullableT(a: Any?): T? = a as T?
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package foo
|
||||
|
||||
trait A
|
||||
interface A
|
||||
|
||||
class AImpl: A
|
||||
|
||||
@@ -15,4 +15,4 @@ fun box(): String {
|
||||
failsClassCast("test(object{})") { test(object{}) }
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package foo
|
||||
|
||||
// CHECK_NOT_CALLED: test
|
||||
|
||||
trait A
|
||||
interface A
|
||||
|
||||
class AImpl: A
|
||||
|
||||
inline
|
||||
fun test<reified T>(x: Any?): T = x as T
|
||||
fun <reified T> test(x: Any?): T = x as T
|
||||
|
||||
fun box(): String {
|
||||
var a: A = AImpl()
|
||||
@@ -18,4 +18,4 @@ fun box(): String {
|
||||
failsClassCast("test(object{})") { test<A>(object{}) }
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ interface A
|
||||
class AImpl : A {}
|
||||
|
||||
inline
|
||||
fun test<reified T>(x: Any?): T = x as T
|
||||
fun <reified T> test(x: Any?): T = x as T
|
||||
|
||||
fun box(): String {
|
||||
var a: A? = AImpl()
|
||||
@@ -16,4 +16,4 @@ fun box(): String {
|
||||
failsClassCast("test(object{})") { test<A?>(object{}) }
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ interface A
|
||||
class AImpl : A {}
|
||||
|
||||
inline
|
||||
fun test<reified T>(x: Any?): T? = x as T?
|
||||
fun <reified T> test(x: Any?): T? = x as T?
|
||||
|
||||
fun box(): String {
|
||||
var a: A? = AImpl()
|
||||
@@ -16,4 +16,4 @@ fun box(): String {
|
||||
failsClassCast("test(object{})") { test<A>(object{}) }
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ open class A
|
||||
class B : A()
|
||||
class C
|
||||
|
||||
fun notNullToNullableT<T : A>(a: Any): T? = a as? T?
|
||||
fun <T : A> notNullToNullableT(a: Any): T? = a as? T?
|
||||
|
||||
fun nullableToNullableT<T : A>(a: Any?): T? = a as? T?
|
||||
fun <T : A> nullableToNullableT(a: Any?): T? = a as? T?
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ class A
|
||||
class B
|
||||
|
||||
inline
|
||||
fun Any?.castTo<reified T>(): T? = this as? T
|
||||
fun <reified T> Any?.castTo(): T? = this as? T
|
||||
|
||||
fun box(): String {
|
||||
val a: Any? = A()
|
||||
@@ -18,4 +18,4 @@ fun box(): String {
|
||||
assertEquals(null, b.castTo<A>(), "b")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ class A
|
||||
class B
|
||||
|
||||
inline
|
||||
fun Any?.castTo<reified T>(): T? = this as? T?
|
||||
fun <reified T> Any?.castTo(): T? = this as? T?
|
||||
|
||||
fun box(): String {
|
||||
val a: Any? = A()
|
||||
@@ -18,4 +18,4 @@ fun box(): String {
|
||||
assertEquals(null, b.castTo<A>(), "b")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user