Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…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
- Loading branch information
1 parent
5d5cd86
commit b706e34
Showing
13 changed files
with
167 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...roposal-decorators/test/fixtures/transformation/initiailzer-after-super-bug-8808/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@decorator(parameter) | ||
class Sub extends Super { | ||
constructor() { | ||
super().method(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...oposal-decorators/test/fixtures/transformation/initiailzer-after-super-bug-8808/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let Sub = babelHelpers.decorate([decorator(parameter)], function (_initialize, _Super) { | ||
"use strict"; | ||
|
||
class Sub extends _Super { | ||
constructor() { | ||
var _temp; | ||
|
||
(_temp = super(), _initialize(this), _temp).method(); | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: Sub, | ||
d: [] | ||
}; | ||
}, Super); |
7 changes: 7 additions & 0 deletions
7
...proposal-decorators/test/fixtures/transformation/initialize-after-super-bug-8931/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@dec | ||
class B extends A { | ||
constructor() { | ||
super(); | ||
[]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...roposal-decorators/test/fixtures/transformation/initialize-after-super-bug-8931/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
let B = babelHelpers.decorate([dec], function (_initialize, _A) { | ||
"use strict"; | ||
|
||
class B extends _A { | ||
constructor() { | ||
super(); | ||
|
||
_initialize(this); | ||
|
||
[]; | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: B, | ||
d: [] | ||
}; | ||
}, A); |
6 changes: 6 additions & 0 deletions
6
...oposal-decorators/test/fixtures/transformation/initialize-after-super-expression/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@dec | ||
class B extends A { | ||
constructor() { | ||
(0, super()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...posal-decorators/test/fixtures/transformation/initialize-after-super-expression/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let B = babelHelpers.decorate([dec], function (_initialize, _A) { | ||
"use strict"; | ||
|
||
class B extends _A { | ||
constructor() { | ||
var _temp; | ||
|
||
0, (_temp = super(), _initialize(this), _temp); | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: B, | ||
d: [] | ||
}; | ||
}, A); |
14 changes: 14 additions & 0 deletions
14
...proposal-decorators/test/fixtures/transformation/initialize-after-super-multiple/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@dec | ||
class B extends A { | ||
constructor() { | ||
const foo = () => { super(); }; | ||
|
||
if (a) { super(); } | ||
else { foo(); } | ||
|
||
while (0) { super(); } | ||
|
||
super(); | ||
} | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
...roposal-decorators/test/fixtures/transformation/initialize-after-super-multiple/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
let B = babelHelpers.decorate([dec], function (_initialize, _A) { | ||
"use strict"; | ||
|
||
class B extends _A { | ||
constructor() { | ||
const foo = () => { | ||
super(); | ||
|
||
_initialize(this); | ||
}; | ||
|
||
if (a) { | ||
super(); | ||
|
||
_initialize(this); | ||
} else { | ||
foo(); | ||
} | ||
|
||
while (0) { | ||
super(); | ||
|
||
_initialize(this); | ||
} | ||
|
||
super(); | ||
|
||
_initialize(this); | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: B, | ||
d: [] | ||
}; | ||
}, A); |
6 changes: 6 additions & 0 deletions
6
...roposal-decorators/test/fixtures/transformation/initialize-after-super-statement/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@dec | ||
class B extends A { | ||
constructor() { | ||
super(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...oposal-decorators/test/fixtures/transformation/initialize-after-super-statement/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let B = babelHelpers.decorate([dec], function (_initialize, _A) { | ||
"use strict"; | ||
|
||
class B extends _A { | ||
constructor() { | ||
super(); | ||
|
||
_initialize(this); | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: B, | ||
d: [] | ||
}; | ||
}, A); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters