title: Closure problems in class definition
body: <p>I'm using CoffeScript to create an angular application.</p>
  
  <p>I have a strange problem with this code.</p>
  
  <p><strong>webService.coffe (simplificated)</strong></p>
  
  <pre><code>ServiceManager.service "webService", class
      constructor : (@$http) -&gt;
  
      # Private
  
      handleResult = (callback, errorCallback, authErrorCallback) =&gt;
          (result) =&gt;
              if result.result then callback result
              else
                  if result.code is 102 then @logout authErrorCallback, errorCallback
                  else errorCallback result.code, result.error
  
      get : (url, callback, errorCallback) -&gt;
          @$http.get url
          .success handleResult callback, errorCallback, (=&gt; @get url, callback, errorCallback)
          .error handleError errorCallback
  
      logout : (callback, errorCallback) -&gt;
          @$http.get "logout"
          .success callback()
          .error errorCallback()
  </code></pre>
  
  <p>In this simplificated code, I get the error <code>_Class.logout is not a function</code> when <code>handleResult</code> is called and the error code is 102.</p>
  
  <p>The <code>=&gt;</code> operator should resolve this problem but it's not. I don't understand why...</p>
  
  <hr>
  
  <p><strong>Javascript compiled code of webService.coffee</strong></p>
  
  <pre><code>ServiceManager.service("webService", (function() {
    var handleResult;
  
    function _Class($http) {
      this.$http = $http;
    }
  
    handleResult = function(callback, errorCallback, authErrorCallback) {
      return function(result) {
        if (result.result) {
          return callback(result);
        } else {
          if (result.code === 102) {
            return _Class.logout(authErrorCallback, errorCallback);
          } else {
            return errorCallback(result.code, result.error);
          }
        }
      };
    };
  
    _Class.prototype.get = function(url, callback, errorCallback) {
      return this.$http.get(url).success(handleResult(callback, errorCallback, ((function(_this) {
        return function() {
          return _this.get(url, callback, errorCallback);
        };
      })(this)))).error(handleError(errorCallback));
    };
  
    _Class.prototype.logout = function(callback, errorCallback) {
      return this.$http.get("logout").success(callback()).error(errorCallback());
    };
  
    return _Class;
  
  })());
  </code></pre>