fixes #1372: bound class methods with reserved names

This commit is contained in:
Michael Ficarra
2011-05-24 16:49:45 -04:00
parent c8845643e5
commit e64fa71185
3 changed files with 10 additions and 5 deletions

View File

@@ -826,8 +826,8 @@ exports.Class = class Class extends Base
addBoundFunctions: (o) ->
if @boundFuncs.length
for bvar in @boundFuncs
bname = bvar.compile o
@ctor.body.unshift new Literal "this.#{bname} = #{utility 'bind'}(this.#{bname}, this)"
lhs = (new Value (new Literal "this"), [new Access bvar]).compile o
@ctor.body.unshift new Literal "#{lhs} = #{utility 'bind'}(#{lhs}, this)"
# Merge the properties from a top-level object as prototypal properties
# on the class.