KT-2752: when simple name of class is a JS keyword or a well-known global name, add '$' to name of constructor function

This commit is contained in:
Alexey Andreev
2016-09-13 17:11:44 +03:00
parent a4bf058be6
commit e7e6a917eb
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.js.translate.initializer;
import com.google.dart.compiler.backend.js.JsReservedIdentifiers;
import com.google.dart.compiler.backend.js.ast.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.*;
@@ -94,6 +95,11 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
}
if (functionName != null) {
if (JsReservedIdentifiers.reservedGlobalSymbols.contains(functionName) ||
JsFunctionScope.Companion.getRESERVED_WORDS().contains(functionName)
) {
functionName += "$";
}
ctorFunction.setName(ctorFunction.getScope().declareName(functionName));
}