[K/N] Rework is checks and as casts codegeneration
^KT-58707 ^KT-59022
This commit is contained in:
committed by
Space Team
parent
b2212b9275
commit
f2520a9cb7
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
|
||||
abstract class A {
|
||||
abstract val x: Any
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
interface A {}
|
||||
|
||||
fun <E> getA() = (object : A {}) as A
|
||||
|
||||
fun box() : String {
|
||||
return if (getA<Int>() is A) "OK" else "FAIL"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6, WASM
|
||||
@file:Suppress("INCOMPATIBLE_TYPES", "UNCHECKED_CAST")
|
||||
|
||||
fun <T> unchecked(x: Any?) = x as T
|
||||
|
||||
fun box() : String{
|
||||
if (unchecked<String>(null) is Any) return "FAIL 1"
|
||||
if (unchecked<String>(null) is IntArray) return "FAIL 2"
|
||||
try {
|
||||
unchecked<String>(null) as Any
|
||||
return "FAIL 3"
|
||||
} catch (e: NullPointerException) {
|
||||
}
|
||||
try {
|
||||
unchecked<String>(null) as IntArray
|
||||
return "FAIL 4"
|
||||
} catch (e: NullPointerException) {
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user