Skip to content

Commit

Permalink
fix(transformer/async-to-generator): incorrect transform when super e…
Browse files Browse the repository at this point in the history
…xpression is inside async method
  • Loading branch information
Dunqing committed Nov 8, 2024
1 parent 9d4633c commit 67e7aa4
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 71 deletions.
457 changes: 403 additions & 54 deletions crates/oxc_transformer/src/common/arrow_function_converter.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/es2017/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod async_to_generator;
pub(crate) mod async_to_generator;
mod options;

use oxc_ast::ast::{Expression, Function, Statement};
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/es2018/mod.rs
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;

Expand Down
12 changes: 3 additions & 9 deletions tasks/transform_conformance/snapshots/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: d20b314c

Passed: 314/626
Passed: 316/626

# All Passed:
* babel-plugin-transform-class-static-block
Expand All @@ -13,7 +13,7 @@ Passed: 314/626
* babel-plugin-transform-react-jsx-source


# babel-preset-env (40/127)
# babel-preset-env (41/127)
* dynamic-import/auto-esm-unsupported-import-unsupported/input.mjs
x Output mismatch

Expand Down Expand Up @@ -107,9 +107,6 @@ x Output mismatch
* plugins-integration/issue-7527/input.mjs
x Output mismatch

* plugins-integration/issue-9935/input.js
x Output mismatch

* plugins-integration/regression-2892/input.mjs
x Output mismatch

Expand Down Expand Up @@ -463,7 +460,7 @@ x Output mismatch
x Output mismatch


# babel-plugin-transform-async-to-generator (10/24)
# babel-plugin-transform-async-to-generator (11/24)
* assumption-ignoreFunctionLength-true/basic/input.mjs
x Output mismatch

Expand All @@ -476,9 +473,6 @@ x Output mismatch
* async-to-generator/async-iife-with-regenerator-spec/input.js
x Output mismatch

* async-to-generator/object-method-with-super/input.js
x Output mismatch

* bluebird-coroutines/arrow-function/input.js
x Output mismatch

Expand Down
8 changes: 2 additions & 6 deletions tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
commit: d20b314c

Passed: 79/89
Passed: 82/91

# All Passed:
* babel-plugin-transform-class-static-block
* babel-plugin-transform-nullish-coalescing-operator
* babel-plugin-transform-optional-catch-binding
* babel-plugin-transform-async-generator-functions
* babel-plugin-transform-async-to-generator
* babel-plugin-transform-exponentiation-operator
* babel-plugin-transform-arrow-functions
* babel-preset-typescript
* babel-plugin-transform-react-jsx-source
* regexp


# babel-plugin-transform-async-to-generator (8/9)
* object/property-with-function/input.js
x Output mismatch


# babel-plugin-transform-typescript (2/9)
* class-property-definition/input.ts
Unresolved references mismatch:
Expand Down
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;
}
}
}
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;
};
})();
}
};
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']();
}
}
}
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']();
}
})();
}
}

0 comments on commit 67e7aa4

Please sign in to comment.