-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transformer/async-to-generator): incorrect transform when super e…
…xpression is inside async method (#7171) After transformation, super expressions have moved to unexpected places. This PR replaces super expression to call expression, and then inserts the super methods to the top of the method body. For example: Before: ```js class G { async method() { super.foo() } } ``` After: ```js class G { method() { var _superprop_getFoo = () => super.foo, _this = this; return _asyncToGenerator(function* () { _superprop_getFoo().call(_this); })(); } }```
- Loading branch information
Showing
12 changed files
with
485 additions
and
87 deletions.
There are no files selected for viewing
449 changes: 394 additions & 55 deletions
449
crates/oxc_transformer/src/common/arrow_function_converter.rs
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod async_generator_functions; | ||
pub(crate) mod async_generator_functions; | ||
mod object_rest_spread; | ||
mod options; | ||
|
||
|
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
commit: d20b314c | ||
|
||
Passed: 80/89 | ||
Passed: 82/91 | ||
|
||
# All Passed: | ||
* babel-plugin-transform-class-static-block | ||
|
10 changes: 10 additions & 0 deletions
10
...mance/tests/babel-plugin-transform-async-to-generator/test/fixtures/super/assign/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,10 @@ | ||
const Obj = { | ||
value: 0, | ||
async method() { | ||
super.value = true; | ||
() => { | ||
super['value'] = true; | ||
super.object.value = true; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ance/tests/babel-plugin-transform-async-to-generator/test/fixtures/super/assign/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,15 @@ | ||
const Obj = { | ||
value: 0, | ||
method() { | ||
var _superprop_getObject = () => super.object, | ||
_superprop_set = (_prop, _value) => super[_prop] = _value, | ||
_superprop_setValue = _value2 => super.value = _value2; | ||
return babelHelpers.asyncToGenerator(function* () { | ||
_superprop_setValue(true); | ||
() => { | ||
_superprop_set('value', true); | ||
_superprop_getObject().value = true; | ||
}; | ||
})(); | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
...ts/babel-plugin-transform-async-to-generator/test/fixtures/super/computed-member/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,9 @@ | ||
class Foo extends class {} { | ||
async method() { | ||
super['name']; | ||
{ | ||
super['name'](); | ||
super['object']['name'](); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...s/babel-plugin-transform-async-to-generator/test/fixtures/super/computed-member/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,13 @@ | ||
class Foo extends class {} { | ||
method() { | ||
var _superprop_get = _prop => super[_prop], | ||
_this = this; | ||
return babelHelpers.asyncToGenerator(function* () { | ||
_superprop_get('name'); | ||
{ | ||
_superprop_get('name').call(_this); | ||
_superprop_get('object')['name'](); | ||
} | ||
})(); | ||
} | ||
} |