Remap across arrow function boundaries - fixes T7108
This commit is contained in:
@@ -19,7 +19,7 @@ function shouldShadow(path, shadowPath) {
|
||||
if (path.is("_forceShadow")) {
|
||||
return true;
|
||||
} else {
|
||||
return shadowPath && !shadowPath.isArrowFunctionExpression();
|
||||
return shadowPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ function remap(path, key, create) {
|
||||
|
||||
if (path.isProgram()) {
|
||||
return true;
|
||||
} else if (path.isFunction()) {
|
||||
} else if (path.isFunction() && !path.isArrowFunctionExpression()) {
|
||||
if (shadowFunction) {
|
||||
return path === shadowFunction || path.node === shadowFunction.node;
|
||||
} else {
|
||||
|
||||
33
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/T7108/actual.js
vendored
Normal file
33
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/T7108/actual.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
class Test{
|
||||
static async method1() {
|
||||
console.log(this);
|
||||
|
||||
setTimeout(async () => {
|
||||
console.log(this);
|
||||
});
|
||||
}
|
||||
|
||||
static async method2() {
|
||||
console.log(this);
|
||||
|
||||
setTimeout(async (arg) => {
|
||||
console.log(this);
|
||||
});
|
||||
}
|
||||
|
||||
async method1() {
|
||||
console.log(this);
|
||||
|
||||
setTimeout(async () => {
|
||||
console.log(this);
|
||||
});
|
||||
}
|
||||
|
||||
async method2() {
|
||||
console.log(this);
|
||||
|
||||
setTimeout(async (arg) => {
|
||||
console.log(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
61
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/T7108/expected.js
vendored
Normal file
61
packages/babel-plugin-transform-async-to-generator/test/fixtures/regression/T7108/expected.js
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
class Test {
|
||||
static method1() {
|
||||
var _this = this;
|
||||
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this);
|
||||
|
||||
setTimeout(babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this);
|
||||
}));
|
||||
})();
|
||||
}
|
||||
|
||||
static method2() {
|
||||
var _this2 = this;
|
||||
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this2);
|
||||
|
||||
setTimeout((() => {
|
||||
var ref = babelHelpers.asyncToGenerator(function* (arg) {
|
||||
console.log(_this2);
|
||||
}),
|
||||
_this = _this2;
|
||||
return function (_x) {
|
||||
return ref.apply(_this, arguments);
|
||||
};
|
||||
})());
|
||||
})();
|
||||
}
|
||||
|
||||
method1() {
|
||||
var _this3 = this;
|
||||
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this3);
|
||||
|
||||
setTimeout(babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this3);
|
||||
}));
|
||||
})();
|
||||
}
|
||||
|
||||
method2() {
|
||||
var _this4 = this;
|
||||
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
console.log(_this4);
|
||||
|
||||
setTimeout((() => {
|
||||
var ref = babelHelpers.asyncToGenerator(function* (arg) {
|
||||
console.log(_this4);
|
||||
}),
|
||||
_this = _this4;
|
||||
return function (_x2) {
|
||||
return ref.apply(_this, arguments);
|
||||
};
|
||||
})());
|
||||
})();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user