mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 09:17:55 -05:00
Fixing class extends this in a non-class context.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user