Skip to content

Commit

Permalink
Issue #1598 -- enabling super() calls in static functions in class bo…
Browse files Browse the repository at this point in the history
…dies.
  • Loading branch information
jashkenas committed Aug 14, 2011
1 parent c6c988a commit 50982b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 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.

9 changes: 7 additions & 2 deletions src/nodes.coffee
Expand Up @@ -475,7 +475,10 @@ exports.Call = class Call extends Base
{name} = method
throw SyntaxError 'cannot call super on an anonymous function.' unless name?
if method.klass
(new Value (new Literal method.klass), [new Access(new Literal "__super__"), new Access new Literal name]).compile o
accesses = [new Access(new Literal '__super__')]
accesses.push new Access new Literal 'constructor' if method.static
accesses.push new Access new Literal name
(new Value (new Literal method.klass), accesses).compile o
else
"#{name}.__super__.constructor"

Expand Down Expand Up @@ -856,7 +859,9 @@ exports.Class = class Class extends Base
@externalCtor = o.scope.freeVariable 'class'
assign = new Assign new Literal(@externalCtor), func
else
unless assign.variable.this
if assign.variable.this
func.static = yes
else
assign.variable = new Value(new Literal(name), [(new Access new Literal 'prototype'), new Access base ])
if func instanceof Code and func.bound
@boundFuncs.push base
Expand Down

0 comments on commit 50982b6

Please sign in to comment.