| Index: pkg/compiler/lib/src/js_backend/namer.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
|
| index 9308dc16b2ef2f0271c0409e0f98c54fe9621686..1fd8d6086b69dba429a982e29b7eef62e07a6195 100644
|
| --- a/pkg/compiler/lib/src/js_backend/namer.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/namer.dart
|
| @@ -101,7 +101,7 @@ part of js_backend;
|
| * For local variables, the [Namer] only provides *proposed names*. These names
|
| * must be disambiguated elsewhere.
|
| */
|
| -class Namer implements ClosureNamer {
|
| +class Namer {
|
|
|
| static const List<String> javaScriptKeywords = const <String>[
|
| // These are current keywords.
|
| @@ -663,14 +663,24 @@ class Namer implements ClosureNamer {
|
| ClassElement enclosingClass = element.enclosingClass;
|
|
|
| if (element.hasFixedBackendName) {
|
| - // Box fields and certain native fields must be given a specific name.
|
| - // Native names must not contain '$'. We rely on this to avoid clashes.
|
| - assert(element is BoxFieldElement ||
|
| - enclosingClass.isNative && !element.fixedBackendName.contains(r'$'));
|
| + // Certain native fields must be given a specific name. Native names must
|
| + // not contain '$'. We rely on this to avoid clashes.
|
| + assert(enclosingClass.isNative &&
|
| + !element.fixedBackendName.contains(r'$'));
|
|
|
| return element.fixedBackendName;
|
| }
|
|
|
| + // Instances of BoxFieldElement are special. They are already created with
|
| + // a unique and safe name. However, as boxes are not really instances of
|
| + // classes, the usual naming scheme that tries to avoid name clashes with
|
| + // super classes does not apply. We still do not mark the name as a
|
| + // fixedBackendName, as we want to allow other namers to do something more
|
| + // clever with them.
|
| + if (element is BoxFieldElement) {
|
| + return element.name;
|
| + }
|
| +
|
| // If the name of the field might clash with another field,
|
| // use a mangled field name to avoid potential clashes.
|
| // Note that if the class extends a native class, that native class might
|
| @@ -972,20 +982,6 @@ class Namer implements ClosureNamer {
|
| return name;
|
| }
|
|
|
| - /// Generate a unique name for the [id]th closure variable, with proposed name
|
| - /// [name].
|
| - ///
|
| - /// The result is used as the name of [BoxFieldElement]s and
|
| - /// [ClosureFieldElement]s, and must therefore be unique to avoid breaking an
|
| - /// invariant in the element model (classes cannot declare multiple fields
|
| - /// with the same name).
|
| - ///
|
| - /// Since the result is used as an element name, it will later show up as a
|
| - /// *proposed name* when the element is passed to [instanceFieldPropertyName].
|
| - String getClosureVariableName(String name, int id) {
|
| - return "${name}_$id";
|
| - }
|
| -
|
| /**
|
| * Returns a proposed name for the given top-level or static element.
|
| * The returned id is guaranteed to be a valid JS-id.
|
|
|