diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index 4985d115..7178ce70 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -2846,7 +2846,7 @@ return node instanceof Literal && node.value === 'arguments' && !node.asKey; }, literalThis: function(node) { - return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound); + return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); } }; diff --git a/src/nodes.coffee b/src/nodes.coffee index 73cb0ae8..753869eb 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1931,7 +1931,8 @@ Closure = literalThis: (node) -> (node instanceof Literal and node.value is 'this' and not node.asKey) or - (node instanceof Code and node.bound) + (node instanceof Code and node.bound) or + (node instanceof Call and node.isSuper) # Unfold a node's child if soak, then tuck the node under created `If` unfoldSoak = (o, parent, name) -> diff --git a/test/scope.coffee b/test/scope.coffee index 21f129ba..1847f11d 100644 --- a/test/scope.coffee +++ b/test/scope.coffee @@ -77,4 +77,18 @@ test "#1183: super + wrap", -> constructor : -> super B::m = -> r = try super() eq (new B()).m(), 10 + +test "#1183: super + closures", -> + class A + constructor: -> + @i = 10 + foo : -> @i + class B extends A + foo : -> + ret = switch 1 + when 0 then 0 + when 1 then super() + ret + eq (new B()).foo(), 10 +