Skip to content

Commit

Permalink
[dart2js] Handle non-identifier characters in member names
Browse files Browse the repository at this point in the history
These occur in the top members generated for extension members.

Change-Id: Ief2e2be0af3c30d7040a9239171db76e49ad0224
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114505
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
  • Loading branch information
johnniwinther authored and commit-bot@chromium.org committed Aug 27, 2019
1 parent 7c6cab9 commit 71f1a61
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/compiler/lib/src/js_backend/namer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,10 @@ class Namer extends ModularNamer {
// apply. So we can directly grab a name.
if (element is JSEntity) {
return _disambiguateInternalMember(
element, () => (element as JSEntity).declaredName);
element,
() => (element as JSEntity)
.declaredName
.replaceAll(_nonIdentifierRE, '_'));
}

// If the name of the field might clash with another field,
Expand Down Expand Up @@ -1257,7 +1260,7 @@ class Namer extends ModularNamer {
ClassEntity enclosingClass = element.enclosingClass;
return '${enclosingClass.name}_${element.name}';
}
return element.name.replaceAll('+', '_');
return element.name.replaceAll(_nonIdentifierRE, '_');
}

String _proposeNameForLazyStaticGetter(MemberEntity element) {
Expand Down

0 comments on commit 71f1a61

Please sign in to comment.