[js_interop] Use safe name when creating JSExport intermediary var.

Bug: https://github.com/dart-lang/sdk/issues/61140
Change-Id: I01b863338f8cfa01150073286f83820ffe39c256
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441280
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Nate Biggs
2025-07-18 11:00:31 -07:00
committed by Commit Queue
parent f033010c63
commit aca53b24db
@@ -50,6 +50,8 @@ class SharedInteropTransformer extends Transformer {
final TypeEnvironment _typeEnvironment;
final Procedure _typeofEquals;
int exportNameIdentifierCounter = 0;
StaticInvocation get invocation => _invocation!;
SharedInteropTransformer(
@@ -395,7 +397,9 @@ class SharedInteropTransformer extends Transformer {
// A new map VariableDeclaration is created and added to the block of
// statements for each export name.
var getSetMap = VariableDeclaration(
'#${exportName}Mapping',
// Don't use the exportName here because it might not be a valid JS
// identifier.
'#${exportNameIdentifierCounter++}Mapping',
initializer: getLiteral(),
type: ExtensionType(_jsObject, Nullability.nonNullable),
isSynthesized: true,