| Index: lib/src/codegen/js_codegen.dart
|
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
|
| index f89564d9eaa16176e00d5161f22de7f2b3f3b6f6..632e8c18a98052dac7b4ec61c4df4a230412fdca 100644
|
| --- a/lib/src/codegen/js_codegen.dart
|
| +++ b/lib/src/codegen/js_codegen.dart
|
| @@ -558,21 +558,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| new JS.ArrayInitializer(
|
| classElem.interfaces.map(_emitTypeName).toList())
|
| ]));
|
| -
|
| - // If a concrete class implements one of our extensions, we might need to
|
| - // add forwarders.
|
| - var extensions = _extensionsToImplement(classElem);
|
| - if (extensions.isNotEmpty) {
|
| - var methodNames = [];
|
| - for (var e in extensions) {
|
| - methodNames.add(_emitMemberDeclarationName(e));
|
| - }
|
| - body.add(js.statement('dart.defineExtensionMembers(#, #);', [
|
| - name,
|
| - new JS.ArrayInitializer(methodNames,
|
| - multiline: methodNames.length > 4)
|
| - ]));
|
| - }
|
| }
|
|
|
| // Named constructors
|
| @@ -608,7 +593,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| classElem.lookUpInheritedConcreteMethod(name, currentLibrary);
|
| if (inheritedElement != null &&
|
| inheritedElement.type == element.type) continue;
|
| - var memberName = _emitMemberDeclarationName(element);
|
| + var memberName = _elementMemberName(element);
|
| var parts =
|
| _emitFunctionTypeParts(element.type, dynamicIsBottom: false);
|
| var property =
|
| @@ -655,6 +640,20 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| }
|
| }
|
|
|
| + // If a concrete class implements one of our extensions, we might need to
|
| + // add forwarders.
|
| + var extensions = _extensionsToImplement(classElem);
|
| + if (extensions.isNotEmpty) {
|
| + var methodNames = [];
|
| + for (var e in extensions) {
|
| + methodNames.add(_elementMemberName(e, declaration: true));
|
| + }
|
| + body.add(js.statement('dart.defineExtensionMembers(#, #);', [
|
| + name,
|
| + new JS.ArrayInitializer(methodNames, multiline: methodNames.length > 4)
|
| + ]));
|
| + }
|
| +
|
| return _statement(body);
|
| }
|
|
|
| @@ -1048,7 +1047,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| var params = _visit(node.parameters);
|
| if (params == null) params = [];
|
|
|
| - return new JS.Method(_emitMemberDeclarationName(node.element),
|
| + return new JS.Method(_elementMemberName(node.element, declaration: true),
|
| new JS.Fun(params, _visit(node.body)),
|
| isGetter: node.isGetter,
|
| isSetter: node.isSetter,
|
| @@ -2524,7 +2523,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| ///
|
| /// Unlike call sites, we always have an element available, so we can use it
|
| /// directly rather than computing the relevant options for [_emitMemberName].
|
| - JS.Expression _emitMemberDeclarationName(ExecutableElement e) {
|
| + JS.Expression _elementMemberName(ExecutableElement e,
|
| + {bool declaration: false}) {
|
| String name;
|
| if (e is PropertyAccessorElement) {
|
| name = e.variable.name;
|
| @@ -2535,7 +2535,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| type: (e.enclosingElement as ClassElement).type,
|
| unary: e.parameters.isEmpty,
|
| isStatic: e.isStatic,
|
| - declaration: true);
|
| + declaration: declaration);
|
| }
|
|
|
| /// This handles member renaming for private names and operators.
|
| @@ -2599,9 +2599,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| }
|
|
|
| // Dart "extension" methods. Used for JS Array, Boolean, Number, String.
|
| - if (!declaration && _extensionTypes.contains(type.element)) {
|
| - // Special case `length`. We can call it directly.
|
| - if (name != 'length') return js.call('dartx.#', _propertyName(name));
|
| + // Special case `length`. We can call it directly.
|
| + if (_extensionTypes.contains(type.element) && name != 'length') {
|
| + var code = declaration ? 'dart.extensionMember(#)' : 'dartx.#';
|
| + return js.call(code, _propertyName(name));
|
| }
|
|
|
| return _propertyName(name);
|
|
|