[JS IR] Generate a key using hashedMangle for all IR declarations in mapToKey

It is required to avoid "key" clashes and failing with ISE.
This commit is contained in:
Zalim Bashorov
2020-12-08 01:01:59 +03:00
parent 7c5ea414b7
commit bc9828f3f3
@@ -29,7 +29,7 @@ import java.util.*
// TODO remove direct usages of [mapToKey] from [NameTable] & co and move it to scripting & REPL infrastructure. Review usages. // TODO remove direct usages of [mapToKey] from [NameTable] & co and move it to scripting & REPL infrastructure. Review usages.
private fun <T> mapToKey(declaration: T): String { private fun <T> mapToKey(declaration: T): String {
return with(JsManglerIr) { return with(JsManglerIr) {
if (declaration is IrDeclaration && isPublic(declaration)) { if (declaration is IrDeclaration) {
declaration.hashedMangle.toString() declaration.hashedMangle.toString()
} else if (declaration is Signature) { } else if (declaration is Signature) {
declaration.toString().hashMangle.toString() declaration.toString().hashMangle.toString()
@@ -39,9 +39,6 @@ private fun <T> mapToKey(declaration: T): String {
} }
} }
private fun JsManglerIr.isPublic(declaration: IrDeclaration) =
declaration.isExported() && declaration !is IrScript && declaration !is IrVariable && declaration !is IrValueParameter
class NameTable<T>( class NameTable<T>(
val parent: NameTable<*>? = null, val parent: NameTable<*>? = null,
val reserved: MutableSet<String> = mutableSetOf(), val reserved: MutableSet<String> = mutableSetOf(),