[JS] Forbid export of interfaces

With the only exception of external interfaces.

See https://youtrack.jetbrains.com/issue/KT-44099
This commit is contained in:
Shagen Ogandzhanian
2020-12-29 20:43:57 +01:00
parent a6534c4653
commit 55a5695fc0
6 changed files with 30 additions and 9 deletions
@@ -107,14 +107,18 @@ object JsExportDeclarationChecker : DeclarationChecker {
checkTypeParameter(typeParameter)
}
if (descriptor.kind == ENUM_CLASS) {
reportWrongExportedDeclaration("enum class")
return
}
if (descriptor.kind == ANNOTATION_CLASS) {
reportWrongExportedDeclaration("annotation class")
val wrongDeclaration: String? = when (descriptor.kind) {
ENUM_CLASS -> "enum class"
INTERFACE -> if (descriptor.isExternal) null else "interface"
ANNOTATION_CLASS -> "annotation class"
else -> null
}
if (wrongDeclaration != null) {
reportWrongExportedDeclaration(wrongDeclaration)
return
}
if (descriptor.kind == ENUM_ENTRY) {
// Covered by ENUM_CLASS
return
@@ -1,6 +1,5 @@
// EXPECTED_REACHABLE_NODES: 1282
@JsExport
interface I {
fun ok(): String
}