mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 03:21:20 -05:00
fixing calling super from constructors
This commit is contained in:
@@ -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')
|
||||||
Reference in New Issue
Block a user