[Wasm] Restrict types allowed in JS interop

- Prohibit Any, Array and other unsupported non-external types in JS
  interop context
- Add K1 diagnostic
- Update BE testdata

^KT-57136 Fixed
This commit is contained in:
Svyatoslav Kuzmich
2023-02-28 10:16:13 +01:00
committed by Space Team
parent bb05c8528f
commit 1e91fe155b
15 changed files with 299 additions and 121 deletions
@@ -40,27 +40,6 @@ fun testExterRef() {
null2ExternRef(null)
}
class DataRef
fun notNullDataRef(x: DataRef) {
js("if (x === null) throw 'error'")
}
fun nullDataRef(x: DataRef?) {
js("if (x === null) throw 'error'")
}
fun null2DataRef(x: DataRef?) {
js("if (x !== null) throw 'error'")
}
fun testDataRef() {
val dataRef = DataRef()
notNullDataRef(dataRef)
nullDataRef(dataRef)
null2DataRef(null)
}
fun notNullInt(x: Int) {
js("if (x !== 123) throw 'error'")
}
@@ -133,47 +112,12 @@ fun testFloat() {
null2Float(null)
}
fun notNullNumber(x: Number) {
js("if (x !== 123.5) throw 'error'")
}
fun nullNumber(x: Number?) {
js("if (x !== 123.5) throw 'error'")
}
fun null2Number(x: Number?) {
js("if (x !== null) throw 'error'")
}
fun byte2Number(x: Number) {
js("if (x !== 123) throw 'error'")
}
fun notNullByte2Number(x: Number?) {
js("if (x !== 123) throw 'error'")
}
fun nullByte2Number(x: Number?) {
js("if (x !== null) throw 'error'")
}
fun testNumber() {
notNullNumber(123.5)
nullNumber(123.5)
null2Number(null)
byte2Number(123)
notNullByte2Number(123)
nullByte2Number(null)
}
fun box(): String {
testString()
testExterRef()
testDataRef()
testInt()
testBoolean()
testShort()
testFloat()
testNumber()
return "OK"
}