Closed GoogleCodeExporter closed 9 years ago
I think the fix for this would probably be to update the type annotations on
the externs for Function.prototype.bind, in es5.js, so that the compiler can
figure everything out, the way it does for goog.bind.
Original comment by tbreisac...@google.com
on 8 Apr 2014 at 10:37
I don't think this works. With goog.bind you can write
/** @param {function(this: T, ...)} @param {T} @template T */
goog.bind = ....
But here, you'd have to write something like
/** @this {function(this: T, ...)} @param {T} @template T */
Function.prototype.bind = ...
And the compiler just doesn't understand how to infer the "this:" backwards
into the "@this" function in the same way it can for goog.bind. So I think
this actually needs a patch to the compiler to understand this type of
inference.
(It's particularly confusing to think about - since the point isn't getting the
right "this" in the returned function, but reverse-inferring the "this" in the
input function).
Original comment by s...@google.com
on 15 Apr 2014 at 7:20
Issue tracking has been migrated to github. Please make any further comments on
this issue through https://github.com/google/closure-compiler/issues
Original comment by blic...@google.com
on 1 May 2014 at 6:31
Original comment by blic...@google.com
on 1 May 2014 at 6:34
Original issue reported on code.google.com by
s...@google.com
on 8 Apr 2014 at 10:32