Chromium Code Reviews| Index: lib/src/codegen/js_codegen.dart |
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart |
| index 2a85f77cae73b54bea1a75ceb03ebe27cbfcd755..8be77619d4e130972254cabc9a4d17babfb36048 100644 |
| --- a/lib/src/codegen/js_codegen.dart |
| +++ b/lib/src/codegen/js_codegen.dart |
| @@ -1114,10 +1114,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { |
| // For instance members, we add implicit-this. |
| // For method tear-offs, we ensure it's a bound method. |
| - var code = 'this.#'; |
| - if (element is MethodElement && !inInvocationContext(node)) { |
| - code += '.bind(this)'; |
| - } |
| + var tearOff = element is MethodElement && !inInvocationContext(node); |
| + var code = (tearOff) ? 'dart.tearoff(this, #)' : 'this.#'; |
|
Jennifer Messerly
2015/05/20 16:05:17
I don't think we should call this "tearoff" in gen
Leaf
2015/05/20 16:35:17
So you're saying change dart.bind to both bind the
Jennifer Messerly
2015/05/20 16:50:30
err, I think so :). What do we still use "dart.bin
Leaf
2015/05/20 17:05:56
Apparently nothing. Made the switch.
|
| return js.call(code, member); |
| } |
| @@ -1989,15 +1987,13 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor { |
| } |
| String code; |
| - if (member != null && member is MethodElement) { |
| + if (member != null && member is MethodElement && !isStatic) { |
| // Tear-off methods: explicitly bind it. |
| + // TODO(leafp): Attach runtime types to these static tearoffs |
| if (_requiresStaticDispatch(target, memberId.name)) { |
| return js.call('dart.#.bind(#)', [name, _visit(target)]); |
| } |
| - if (isStateless(target, target)) { |
| - return js.call('#.#.bind(#)', [_visit(target), name, _visit(target)]); |
|
Jennifer Messerly
2015/05/20 16:05:17
this makes me a little sad, as we never generate "
Leaf
2015/05/20 16:35:17
Hmm. I actually kind of felt like it was often an
Jennifer Messerly
2015/05/20 16:50:30
yeah, exactly ... in JS it's not something you'd t
|
| - } |
| - code = 'dart.bind(#, #)'; |
| + code = 'dart.tearoff(#, #)'; |
| } else if (_requiresStaticDispatch(target, memberId.name)) { |
| return js.call('dart.#(#)', [name, _visit(target)]); |
| } else { |