1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fixing calling super from constructors

This commit is contained in:
Jeremy Ashkenas 2010-01-08 10:54:44 -05:00
parent 8b3926fb0c
commit 4c3f00cf77
2 changed files with 17 additions and 1 deletions

View file

@ -243,7 +243,9 @@ module CoffeeScript
def compile_super(args, o)
methname = o[:last_assign]
arg_part = args.empty? ? '' : ", #{args}"
"#{o[:proto_assign]}.__superClass__.#{methname}.call(this#{arg_part})"
meth = o[:proto_assign] ? "#{o[:proto_assign]}.__superClass__.#{methname}" :
"#{methname}.__superClass__.constructor"
"#{meth}.call(this#{arg_part})"
end
def compile_splat(o)

View file

@ -22,3 +22,17 @@ result: (new ThirdChild()).func('four')
print(result is 'zero/one/two/three/four')
TopClass: arg =>
this.prop: 'top-' + arg
SuperClass: arg =>
super('super-' + arg)
SubClass: =>
super('sub')
SuperClass extends TopClass
SubClass extends SuperClass
print((new SubClass()).prop is 'top-super-sub')