Fixing class extends this in a non-class context.

This commit is contained in:
Jeremy Ashkenas
2010-12-23 10:22:52 -08:00
parent 2ec1c3b56c
commit ccfd369a77
3 changed files with 16 additions and 2 deletions

View File

@@ -1049,7 +1049,7 @@
this.ensureConstructor(name);
this.body.expressions.push(lname);
this.addBoundFunctions(o);
klass = new Parens(new Call(new Code([], this.body)), true);
klass = new Parens(Closure.wrap(this.body), true);
if (this.variable) {
klass = new Assign(this.variable, klass);
}

View File

@@ -841,7 +841,7 @@ exports.Class = class Class extends Base
@body.expressions.push lname
@addBoundFunctions o
klass = new Parens new Call(new Code [], @body), true
klass = new Parens Closure.wrap(@body), true
klass = new Assign @variable, klass if @variable
klass.compile o

View File

@@ -354,3 +354,17 @@ class A
@c = -> 5
eq A.B.c(), 5
# `class extends this` ...
class A
func: -> 'A'
B = null
makeClass = ->
B = class extends this
func: -> super + ' B'
makeClass.call A
eq (new B()).func(), 'A B'