Index: lib/src/codegen/js_codegen.dart |
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart |
index 608628ea1af0dbea81b5dc626514f7ff42d5ebd1..a20b3799c0412b9e9cc952b87c0753909900112e 100644 |
--- a/lib/src/codegen/js_codegen.dart |
+++ b/lib/src/codegen/js_codegen.dart |
@@ -1289,12 +1289,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor { |
} |
var fn = _visit(func.functionExpression); |
- var jsThis = new _JsThisFinder(); |
- fn.accept(jsThis); |
var name = new JS.Identifier(func.name.name); |
JS.Statement declareFn; |
- if (jsThis.found) { |
+ if (JS.This.foundIn(fn)) { |
declareFn = js.statement('let # = #.bind(this);', [name, fn]); |
} else { |
declareFn = new JS.FunctionDeclaration(name, fn); |
@@ -2824,7 +2822,9 @@ class JSGenerator extends CodeGenerator { |
new JSCodegenVisitor(compiler, library, _extensionTypes, fields); |
var module = codegen.emitLibrary(unit); |
var out = compiler.getOutputPath(library.source.uri); |
- return writeJsLibrary(module, out, emitSourceMaps: options.emitSourceMaps); |
+ return writeJsLibrary(module, out, |
+ emitSourceMaps: options.emitSourceMaps, |
+ arrowFnBindThisWorkaround: options.arrowFnBindThisWorkaround); |
} |
} |
@@ -2859,13 +2859,3 @@ class TemporaryVariableElement extends LocalVariableElementImpl { |
int get hashCode => identityHashCode(this); |
bool operator ==(Object other) => identical(this, other); |
} |
- |
-class _JsThisFinder extends JS.BaseVisitor { |
- bool found = false; |
- visitThis(JS.This node) { |
- found = true; |
- } |
- visitNode(JS.Node node) { |
- if (!found) super.visitNode(node); |
- } |
-} |