diff --git a/lib/coffee_script/nodes.rb b/lib/coffee_script/nodes.rb index 3fc6d6e9..ce7275ca 100644 --- a/lib/coffee_script/nodes.rb +++ b/lib/coffee_script/nodes.rb @@ -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) diff --git a/test/fixtures/execution/test_calling_super.coffee b/test/fixtures/execution/test_calling_super.coffee index 0dee5757..65de1b0c 100644 --- a/test/fixtures/execution/test_calling_super.coffee +++ b/test/fixtures/execution/test_calling_super.coffee @@ -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') \ No newline at end of file