@@ -1031,7 +1031,7 @@ exports.Class = class Class extends Base
1031
1031
if func instanceof Code
1032
1032
assign = @ctor = func
1033
1033
else
1034
- @externalCtor = o .scope .freeVariable ' class'
1034
+ @externalCtor = o .classScope .freeVariable ' class'
1035
1035
assign = new Assign new Literal (@externalCtor ), func
1036
1036
else
1037
1037
if assign .variable .this
@@ -1098,18 +1098,18 @@ exports.Class = class Class extends Base
1098
1098
lname = new Literal name
1099
1099
func = new Code [], Block .wrap [@body ]
1100
1100
args = []
1101
+ o .classScope = func .makeScope o .scope
1101
1102
1102
1103
@ hoistDirectivePrologue ()
1103
1104
@ setContext name
1104
1105
@ walkBody name, o
1105
1106
@ ensureConstructor name
1106
1107
@ addBoundFunctions o
1107
1108
@body .spaced = yes
1108
- @body .expressions .unshift @ctor unless @ctor instanceof Code
1109
1109
@body .expressions .push lname
1110
1110
1111
1111
if @parent
1112
- superClass = new Literal o .scope .freeVariable ' super' , no
1112
+ superClass = new Literal o .classScope .freeVariable ' super' , no
1113
1113
@body .expressions .unshift new Extends lname, superClass
1114
1114
func .params .push new Param superClass
1115
1115
args .push @parent
@@ -1305,6 +1305,8 @@ exports.Code = class Code extends Base
1305
1305
1306
1306
jumps : NO
1307
1307
1308
+ makeScope : (parentScope ) -> new Scope parentScope, @body , this
1309
+
1308
1310
# Compilation creates a new scope unless explicitly asked to share with the
1309
1311
# outer scope. Handles splat parameters in the parameter list by peeking at
1310
1312
# the JavaScript `arguments` object. If the function is bound with the `=>`
@@ -1320,7 +1322,7 @@ exports.Code = class Code extends Base
1320
1322
boundfunc .updateLocationDataIfMissing @locationData
1321
1323
return boundfunc .compileNode (o)
1322
1324
1323
- o .scope = new Scope o . scope , @body , this
1325
+ o .scope = del (o, ' classScope ' ) or @ makeScope o . scope
1324
1326
o .scope .shared = del (o, ' sharedScope' )
1325
1327
o .indent += TAB
1326
1328
delete o .bare
0 commit comments