[Wasm] Port WasmImport/WasmExport checker to K2 (KT-56849)

This commit is contained in:
Svyatoslav Kuzmich
2023-11-14 12:24:10 +00:00
committed by Space Team
parent 28895a2613
commit 1c230c8f27
14 changed files with 205 additions and 128 deletions
@@ -1,58 +0,0 @@
import kotlin.wasm.WasmExport
@WasmExport("a")
external fun foo0(): Unit
@WasmExport("a")
fun foo1(): Int = js("42")
class C() {
@WasmExport("a")
fun foo2(): Int = 42
}
@WasmExport("a")
fun foo3(): Int = 42
@WasmExport()
fun foo4(): Int = 42
@OptIn(kotlin.js.ExperimentalJsExport::class)
@JsExport()
@WasmExport()
fun foo6(): Int = 42
val p1 = (@WasmExport("a") fun () {})
@WasmExport("a")
fun foo7(
p0: Unit,
p1: String,
p2: Any,
p3: Int?,
p4: Boolean?
): Unit {
p0.toString()
p1.toString()
p2.toString()
p3.toString()
p4.toString()
}
@WasmExport("a")
fun returnNullableUnit(): Unit? { return null }
@WasmExport("a")
fun returnNullableBoolean(): Boolean? { return null }
@WasmExport("a")
fun returnNullableAny(): Any? { return null }
@WasmExport("a")
fun <T> fooGeneric(x: T): T { return x }
@WasmExport("a")
fun fooDeafultAndVararg(
a: Int = <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!>,
vararg b: Int
): Unit { b.toString() }
@@ -1,14 +1,16 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
import kotlin.wasm.WasmExport
<!WASM_EXPORT_ON_EXTERNAL_DECLARATION!>@WasmExport("a")
external fun foo0(): Unit<!>
<!WASM_EXPORT_ON_EXTERNAL_DECLARATION!>@WasmExport("a")<!>
external fun foo0(): Unit
<!WASM_EXPORT_ON_EXTERNAL_DECLARATION!>@WasmExport("a")
fun foo1(): Int = js("42")<!>
<!WASM_EXPORT_ON_EXTERNAL_DECLARATION!>@WasmExport("a")<!>
fun foo1(): Int = js("42")
class C() {
<!NESTED_WASM_EXPORT!>@WasmExport("a")
fun foo2(): Int = 42<!>
<!NESTED_WASM_EXPORT!>@WasmExport("a")<!>
fun foo2(): Int = 42
}
@WasmExport("a")
@@ -22,7 +24,7 @@ fun foo4(): Int = 42
@WasmExport()
fun foo6(): Int = 42<!>
val p1 = (<!NESTED_WASM_EXPORT!>@WasmExport("a") fun () {}<!>)
val p1 = (<!NESTED_WASM_EXPORT!>@WasmExport("a")<!> fun () {})
@WasmExport("a")
fun foo7(
@@ -40,19 +42,19 @@ fun foo7(
}
<!WASM_IMPORT_EXPORT_UNSUPPORTED_RETURN_TYPE!>@WasmExport("a")
fun returnNullableUnit(): Unit? { return null }<!>
fun returnNullableUnit(): Unit?<!> { return null }
<!WASM_IMPORT_EXPORT_UNSUPPORTED_RETURN_TYPE!>@WasmExport("a")
fun returnNullableBoolean(): Boolean? { return null }<!>
fun returnNullableBoolean(): Boolean?<!> { return null }
<!WASM_IMPORT_EXPORT_UNSUPPORTED_RETURN_TYPE!>@WasmExport("a")
fun returnNullableAny(): Any? { return null }<!>
fun returnNullableAny(): Any?<!> { return null }
<!WASM_IMPORT_EXPORT_UNSUPPORTED_RETURN_TYPE!>@WasmExport("a")
fun <T> fooGeneric(<!WASM_IMPORT_EXPORT_UNSUPPORTED_PARAMETER_TYPE!>x: T<!>): T { return x }<!>
fun <T> fooGeneric(<!WASM_IMPORT_EXPORT_UNSUPPORTED_PARAMETER_TYPE!>x: T<!>): T<!> { return x }
@WasmExport("a")
fun fooDeafultAndVararg(
<!WASM_IMPORT_EXPORT_PARAMETER_DEFAULT_VALUE!><!UNUSED_PARAMETER!>a<!>: Int = <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!><!>,
<!WASM_IMPORT_EXPORT_PARAMETER_DEFAULT_VALUE!>a: Int = <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!><!>,
<!WASM_IMPORT_EXPORT_UNSUPPORTED_PARAMETER_TYPE, WASM_IMPORT_EXPORT_VARARG_PARAMETER!>vararg b: Int<!>
): Unit { b.toString() }
@@ -1,49 +0,0 @@
import kotlin.wasm.WasmImport
@WasmImport("a", "b")
external fun foo0(): Unit
@WasmImport("a", "b")
fun foo1() {
}
external class C {
@WasmImport("a", "b")
fun memberFunction()
}
fun foo2() {
@WasmImport("a", "b")
fun localFun() {
}
}
val p1 = (@WasmImport("a", "b") fun () {})
@WasmImport("a", "b")
external fun foo3(
p0: Unit,
p1: String,
p2: Any,
p3: Int?,
p4: Boolean?
): Unit
@WasmImport("a", "b")
external fun returnNullableUnit(): Unit?
@WasmImport("a", "b")
external fun returnNullableBoolean(): Boolean?
@WasmImport("a", "b")
external fun returnNullableAny(): Any?
@WasmImport("a", "b")
external fun <T> fooGeneric(x: T): T
@WasmImport("a", "b")
external fun fooDeafultAndVararg(
a: Int = definedExternally,
vararg b: Int
): Unit
@@ -1,3 +1,5 @@
// FIR_IDENTICAL
import kotlin.wasm.WasmImport
@WasmImport("a", "b")