[decorators] Correctly insert _initialize(this) after super(). (#8970)

* [decorators] Correctly insert `_initialize(this)` after `super()`.

This commit fixes to problem:
1) After `super();` statements, `_initialize(this)` was inserted without
   a trailing semicolon.
2) `(0, super())` causes an infinite recursion.

* Fix tests

* Add test
This commit is contained in:
Nicolò Ribaudo
2018-11-07 06:58:09 +01:00
committed by Daniel Tschinder
parent 5d5cd8612f
commit b706e34fc8
13 changed files with 167 additions and 3 deletions

View File

@@ -113,6 +113,10 @@ const bareSupersVisitor = {
CallExpression(path, { initializeInstanceElements }) {
if (path.get("callee").isSuper()) {
path.insertAfter(t.cloneNode(initializeInstanceElements));
// Sometimes this path gets requeued (e.g. in (super(), foo)), and
// it leads to infinite recursion.
path.skip();
}
},
Function(path) {