Skip to content

Commit b0948f8

Browse files
committed
Fixes #1876
1 parent 00f9e24 commit b0948f8

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

lib/coffee-script/nodes.js

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+10-2
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,20 @@ exports.Class = class Class extends Base
937937
@walkBody name, o
938938
@ensureConstructor name
939939
@body.spaced = yes
940-
@body.expressions.unshift new Extends lname, @parent if @parent
940+
if @parent
941+
@superClass = new Literal o.scope.freeVariable 'super'
942+
@body.expressions.unshift new Extends lname, @superClass
941943
@body.expressions.unshift @ctor unless @ctor instanceof Code
942944
@body.expressions.push lname
943945
@addBoundFunctions o
944946

945-
klass = new Parens Closure.wrap(@body), true
947+
call = Closure.wrap @body
948+
949+
if @parent
950+
call.args.push @parent
951+
call.variable.params.push new Param @superClass
952+
953+
klass = new Parens call, true
946954
klass = new Assign @variable, klass if @variable
947955
klass.compile o
948956

test/classes.coffee

+8-1
Original file line numberDiff line numberDiff line change
@@ -555,4 +555,11 @@ test "#1842: Regression with bound functions within bound class methods", ->
555555

556556
Store.bound()
557557
Store.unbound()
558-
(new Store).instance()
558+
(new Store).instance()
559+
560+
test "#1876: Class @A extends A", ->
561+
class A
562+
class @A extends A
563+
564+
ok (new @A) instanceof A
565+

0 commit comments

Comments
 (0)