[K/JS] Exclude default from the regular reserved keywords to give ability to export declarations with default export ^KT-54480 Fixed
fix(KT-54480): exclude default from the regular reserved keywords to give ability to export intities with default export. Merge-request: KT-MR-7459 Merged-by: Artem Kobzar <Artem.Kobzar@jetbrains.com>
This commit is contained in:
+4
@@ -24,6 +24,10 @@ val bar = 4
|
||||
@JsName(<!NON_CONSUMABLE_EXPORTED_IDENTIFIER!>"super"<!>)
|
||||
class Baz
|
||||
|
||||
@JsExport
|
||||
@JsName("default")
|
||||
class DefDef
|
||||
|
||||
@JsExport
|
||||
class Test {
|
||||
fun instanceof() {}
|
||||
|
||||
+7
@@ -13,6 +13,13 @@ package foo {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.js.JsExport @kotlin.js.JsName(name = "default") public final class DefDef {
|
||||
public constructor DefDef()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.js.JsExport public object NaN {
|
||||
private constructor NaN()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
@@ -51,9 +51,11 @@ fun String.isValidES5Identifier(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
val RESERVED_KEYWORDS: Set<String> = setOf(
|
||||
val SPECIAL_KEYWORDS: Set<String> = setOf("default")
|
||||
|
||||
val RESERVED_KEYWORDS: Set<String> = SPECIAL_KEYWORDS + setOf(
|
||||
// keywords
|
||||
"await", "break", "case", "catch", "continue", "debugger", "default", "delete", "do", "else", "finally", "for", "function", "if",
|
||||
"await", "break", "case", "catch", "continue", "debugger", "delete", "do", "else", "finally", "for", "function", "if",
|
||||
"in", "instanceof", "new", "return", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with",
|
||||
|
||||
// future reserved words
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.*
|
||||
import org.jetbrains.kotlin.js.common.RESERVED_KEYWORDS
|
||||
import org.jetbrains.kotlin.js.common.SPECIAL_KEYWORDS
|
||||
import org.jetbrains.kotlin.js.naming.NameSuggestion
|
||||
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
@@ -212,7 +213,7 @@ object JsExportDeclarationChecker : DeclarationChecker {
|
||||
|
||||
val name = declarationDescriptor.getKotlinOrJsName()
|
||||
|
||||
if (name !in RESERVED_KEYWORDS && NameSuggestion.sanitizeName(name) == name) return
|
||||
if (name in SPECIAL_KEYWORDS || (name !in RESERVED_KEYWORDS && NameSuggestion.sanitizeName(name) == name)) return
|
||||
|
||||
val reportTarget = declarationDescriptor.getJsNameArgument() ?: declaration.getIdentifier()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user