jashkenas/coffee-script — pull request #3228 by marchaefner (2013-11-03 02:17:38+00:00)
Title: Avoid unnecessary wrapping of some bound functions

This fixes a side effect of 392767a0. Unnecessary wrappers are created for:

* bound functions in class bodies, that are not methods (This is related to #1947, which can be closed.)
* bound function within bound functions

Compilation examples at https://gist.github.com/marchaefner/7284379

(PR also removes an assignment to an unused variable.)

#### Theory of Operation

* The context (i.e. `this`) within bound functions will be replaced with the `.context` of the function / `Code` node. (in `Literal::compileNode`)

* `Class` sets `.context` on contained bound functions (but not instance methods) to its name.

* A bound function within a bound function will inherit its context. (This is currently done too late, after deciding whether to wrap.)

* If the context has not been set, and only then, we need to set it to `_this` and wrap the function. (Currently the context is set unconditionally and possibly overridden afterward.)