JS: when RHS of as cast is non-nullable native interface, check LHS for null
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
@native interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
fun createObject(): Any? = null
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
(createObject() as I).foo()
|
||||
return "fail: exception not thrown"
|
||||
}
|
||||
catch (e: ClassCastException) {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
@native interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
fun createObject(): Any? = null
|
||||
|
||||
fun box(): String {
|
||||
val result = (createObject() as I?)?.foo()
|
||||
return if (result == null) "OK" else "fail"
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
var global = ""
|
||||
|
||||
inline fun <reified T> log(x: T) {
|
||||
global += jsClass<T>().name + ": " + x
|
||||
inline fun <reified T : Any> log(x: T) {
|
||||
global += T::class.js.name + ": " + x
|
||||
}
|
||||
|
||||
@native class C {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@native interface I {
|
||||
fun foo(): String
|
||||
}
|
||||
fun createObject(): Any? = null
|
||||
|
||||
fun box(): String {
|
||||
val result = (createObject() as? I)?.foo()
|
||||
return if (result == null) "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user