From f79607d32dcd525d1219f74163ac3d8b5dc00196 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Fri, 17 Feb 2023 16:35:59 +0100 Subject: [PATCH] [Wasm] Add @JsExport diagnostics test @JsExport is only allowed on top-level functions in K/Wasm Restrictions for nested function are handled by reusing K/JS diagnostics Restrictions for classes and properties are handled by specifying annotation target in stdlib --- .../wasmTests/jsInterop/jsExport.kt | 25 +++++++++++++++++++ .../DiagnosticsWasmTestGenerated.java | 6 +++++ 2 files changed, 31 insertions(+) create mode 100644 compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt diff --git a/compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt b/compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt new file mode 100644 index 00000000000..f255fc9e48e --- /dev/null +++ b/compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt @@ -0,0 +1,25 @@ +// !OPT_IN: kotlin.js.ExperimentalJsExport + +@JsExport +fun foo1() { +} + +class C { + @JsExport + fun memberFunction() { + } +} + +fun foo2() { + @JsExport + fun localFun() { + } +} + +val p1 = (@JsExport fun () {}) + +@JsExport +class C2 + +@JsExport +var p2: Int = 1 diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java index 217244e3c8d..e369db6eb8e 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/diagnostics/DiagnosticsWasmTestGenerated.java @@ -50,5 +50,11 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest { public void testInheritance() throws Exception { runTest("compiler/testData/diagnostics/wasmTests/jsInterop/inheritance.kt"); } + + @Test + @TestMetadata("jsExport.kt") + public void testJsExport() throws Exception { + runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt"); + } } }