diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt index 71eff4edbd2..ff10e30baf6 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/JsGenerationContext.kt @@ -43,12 +43,11 @@ class JsGenerationContext { this.currentFunction = func } - fun getNameForDeclaration(declaration: IrDeclaration): JsName = when (declaration) { - is IrSymbolOwner -> getNameForSymbol(declaration.symbol) - // Properties don't have symbols. Handling them separately: - is IrProperty -> currentScope.declareName(declaration.getJsName() ?: declaration.name.identifier) - else -> error("Unsupported") - } + fun getNameForDeclaration(declaration: IrDeclaration): JsName = + if (declaration is IrSymbolOwner) + getNameForSymbol(declaration.symbol) + else + error("Unsupported") fun getNameForSymbol(symbol: IrSymbol): JsName = staticContext.getNameForSymbol(symbol, this) fun getNameForType(type: IrType): JsName = staticContext.getNameForType(type, this) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/SimpleNameGenerator.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/SimpleNameGenerator.kt index 0d5b283d064..502d52a4656 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/SimpleNameGenerator.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/SimpleNameGenerator.kt @@ -47,6 +47,10 @@ class SimpleNameGenerator : NameGenerator { val declarationName = declaration.getJsNameOrKotlinName().asString() + if (declaration is IrProperty) { + return context.currentScope.declareName(declaration.getJsNameOrKotlinName().asString()) + } + if (declaration is IrSimpleFunction && declaration.origin == JsLoweredDeclarationOrigin.BRIDGE_TO_EXTERNAL_FUNCTION) { return nameDeclarator(declarationName) }