Skip to content

Commit

Permalink
Fixes #1876
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Dec 14, 2011
1 parent 00f9e24 commit b0948f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,20 @@ exports.Class = class Class extends Base
@walkBody name, o
@ensureConstructor name
@body.spaced = yes
@body.expressions.unshift new Extends lname, @parent if @parent
if @parent
@superClass = new Literal o.scope.freeVariable 'super'
@body.expressions.unshift new Extends lname, @superClass
@body.expressions.unshift @ctor unless @ctor instanceof Code
@body.expressions.push lname
@addBoundFunctions o

klass = new Parens Closure.wrap(@body), true
call = Closure.wrap @body

if @parent
call.args.push @parent
call.variable.params.push new Param @superClass

klass = new Parens call, true
klass = new Assign @variable, klass if @variable
klass.compile o

Expand Down
9 changes: 8 additions & 1 deletion test/classes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,11 @@ test "#1842: Regression with bound functions within bound class methods", ->

Store.bound()
Store.unbound()
(new Store).instance()
(new Store).instance()

test "#1876: Class @A extends A", ->
class A
class @A extends A

ok (new @A) instanceof A

0 comments on commit b0948f8

Please sign in to comment.