Add mechanism for type coercion in JS
Use it for char boxing/unboxing and unit materialization. Possible to use for other purposes, for example, to add type checks to dynamics. See KT-18793, KT-17915, KT-19081, KT-18216, KT-12970, KT-17014, KT-13932, KT-13930
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// EXPECTED_REACHABLE_NODES: 997
|
||||
fun box(): String {
|
||||
val a = CharArray(1)
|
||||
val aType = jsTypeOf(a.asDynamic()[0])
|
||||
if (aType != "number") return "fail1: $aType"
|
||||
|
||||
a[0] = 'Q'
|
||||
val aType2 = jsTypeOf(a.asDynamic()[0])
|
||||
if (aType2 != "number") return "fail2: $aType2"
|
||||
|
||||
val aType3 = jsTypeOf(a[0].asDynamic())
|
||||
if (aType3 != "number") return "fail3: $aType3"
|
||||
|
||||
val b = Array<Char>(1) { 'Q' }
|
||||
val bType = jsTypeOf(b.asDynamic()[0])
|
||||
if (bType != "object") return "fail4: $bType"
|
||||
|
||||
b[0] = 'W'
|
||||
val bType2 = jsTypeOf(b.asDynamic()[0])
|
||||
if (bType2 != "object") return "fail5: $bType2"
|
||||
|
||||
val bType3 = jsTypeOf(b[0].asDynamic())
|
||||
if (bType3 != "number") return "fail6: $bType3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user