JS_IR: fix property name generation

This commit is contained in:
Dmitry Petrov
2019-02-28 14:58:56 +03:00
parent 04fad012a0
commit 8b4dab7c25
2 changed files with 9 additions and 6 deletions
@@ -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)
@@ -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)
}