[JS] JsExport diagnostics and legacy support

Account for JsExport in legacy backend namer. It means we
catch overloaded exported function conflicts for free!

Add error diagnostics:
* NESTED_JS_EXPORT (Fixes KT-36798)
* WRONG_EXPORTED_DECLARATION (Part of the fix for KT-37752)
* NON_EXPORTABLE_TYPE (Fixes KT-37771)
This commit is contained in:
Svyatoslav Kuzmich
2019-08-29 18:25:09 +03:00
parent 4076bf40a9
commit 6e3d3831c2
52 changed files with 972 additions and 72 deletions
+3 -4
View File
@@ -1,16 +1,15 @@
// SKIP_MINIFICATION
// Exported declaration uses non-exportable return type: Char
// IGNORE_BACKEND: JS_IR
@JsName("foo")
@JsExport
fun foo(): Char = '1'
@JsExport
val p1: Char = '2'
@JsExport
var p2: Char = '3'
@JsExport
var p3: Char = '4'
get() = field + 1
set(value) {
@@ -1,7 +1,6 @@
// EXPECTED_REACHABLE_NODES: 1276
// IGNORE_BACKEND: JS_IR
@JsExport
class A(val x: Char)
fun typeOf(x: dynamic): String = js("typeof x")
@@ -4,7 +4,6 @@ interface I {
val a: Char
}
@JsExport
object X : I {
override var a = '#'
}
@@ -1,7 +1,6 @@
// EXPECTED_REACHABLE_NODES: 1289
// IGNORE_BACKEND: JS_IR
@JsExport
open class A {
val foo: Char
get() = 'X'
@@ -1,5 +1,6 @@
// EXPECTED_REACHABLE_NODES: 1282
@JsExport
interface I {
fun ok(): String
}
@@ -12,7 +12,6 @@ class A {
}
}
@JsExport
val A.z: Int
@JsName("getZ_") get() = 42
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
@file:JsExport
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
@file:JsExport
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
// FILE: file1.kt
@@ -2,7 +2,6 @@ declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
namespace foo {
const _any: any;
const _unit: void;
function _nothing(): never
const _throwable: Error;
const _string: string;
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
@file:JsExport
@@ -8,8 +9,6 @@ package foo
val _any: Any = Any()
val _unit: Unit = Unit
fun _nothing(): Nothing { throw Throwable() }
val _throwable: Throwable = Throwable()
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
// FILE: file1.kt
package foo
@@ -1,6 +1,7 @@
// TARGET_BACKEND: JS_IR
// CHECK_TYPESCRIPT_DECLARATIONS
// RUN_PLAIN_BOX_FUNCTION
// SKIP_MINIFICATION
// SKIP_NODE_JS
// TODO fix statics export in DCE-driven mode
// SKIP_DCE_DRIVEN