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:
parent
8b3926fb0c
commit
4c3f00cf77
2 changed files with 17 additions and 1 deletions
|
@ -243,7 +243,9 @@ module CoffeeScript
|
||||||
def compile_super(args, o)
|
def compile_super(args, o)
|
||||||
methname = o[:last_assign]
|
methname = o[:last_assign]
|
||||||
arg_part = args.empty? ? '' : ", #{args}"
|
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
|
end
|
||||||
|
|
||||||
def compile_splat(o)
|
def compile_splat(o)
|
||||||
|
|
|
@ -22,3 +22,17 @@ result: (new ThirdChild()).func('four')
|
||||||
|
|
||||||
print(result is 'zero/one/two/three/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')
|
Loading…
Add table
Reference in a new issue