Remap across arrow function boundaries - fixes T7108

This commit is contained in:
Logan Smyth
2016-03-06 16:58:54 -08:00
parent 2e210927d8
commit db3a43869c
3 changed files with 96 additions and 2 deletions

View File

@@ -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 {

View 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);
});
}
}

View 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);
};
})());
})();
}
}