Fix non-unique 'ref' binding name - fixes T7468

This commit is contained in:
Logan Smyth 2016-06-28 19:11:28 -07:00
parent e390570f9d
commit 231f27f170
16 changed files with 64 additions and 48 deletions

View File

@ -2,11 +2,12 @@ function f() {
var _this = this; var _this = this;
let g = function () { let g = function () {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref = babelHelpers.asyncToGenerator(function* () {
_this; _this;
}); });
return function g() { return function g() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
}(); }();
}; };
@ -17,11 +18,12 @@ class Class {
return babelHelpers.asyncToGenerator(function* () { return babelHelpers.asyncToGenerator(function* () {
var c = function () { var c = function () {
var ref = babelHelpers.asyncToGenerator(function* (b) { var _ref2 = babelHelpers.asyncToGenerator(function* (b) {
_this2; _this2;
}); });
return function c(_x) { return function c(_x) {
return ref.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
}(); }();
})(); })();

View File

@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var foo = function () { var foo = function () {
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee3() { var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3() {
var bar = function () { var bar = function () {
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee2() { var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2() {
var baz; var baz;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
@ -26,7 +26,7 @@ var foo = function () {
})); }));
return function bar() { return function bar() {
return ref.apply(this, arguments); return _ref3.apply(this, arguments);
}; };
}(); }();
@ -42,7 +42,7 @@ var foo = function () {
})); }));
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
}(); }();
@ -58,7 +58,7 @@ var Foo = function () {
_createClass(Foo, [{ _createClass(Foo, [{
key: "bar", key: "bar",
value: function () { value: function () {
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
var baz; var baz;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
@ -75,7 +75,7 @@ var Foo = function () {
})); }));
function bar() { function bar() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
} }
return bar; return bar;

View File

@ -7,18 +7,18 @@ import * as t from "babel-types";
let buildWrapper = template(` let buildWrapper = template(`
(() => { (() => {
var ref = FUNCTION; var REF = FUNCTION;
return function NAME(PARAMS) { return function NAME(PARAMS) {
return ref.apply(this, arguments); return REF.apply(this, arguments);
}; };
}) })
`); `);
let namedBuildWrapper = template(` let namedBuildWrapper = template(`
(() => { (() => {
var ref = FUNCTION; var REF = FUNCTION;
function NAME(PARAMS) { function NAME(PARAMS) {
return ref.apply(this, arguments); return REF.apply(this, arguments);
} }
return NAME; return NAME;
}) })
@ -76,6 +76,7 @@ function plainFunction(path: NodePath, callId: Object) {
let built = t.callExpression(callId, [node]); let built = t.callExpression(callId, [node]);
let container = wrapper({ let container = wrapper({
NAME: asyncFnId, NAME: asyncFnId,
REF: path.scope.generateUidIdentifier("ref"),
FUNCTION: built, FUNCTION: built,
PARAMS: node.params.map(() => path.scope.generateUidIdentifier("x")) PARAMS: node.params.map(() => path.scope.generateUidIdentifier("x"))
}).expression; }).expression;

View File

@ -5,12 +5,13 @@ let TestClass = {
var _this = this; var _this = this;
return new Promise((() => { return new Promise((() => {
var ref = babelHelpers.asyncToGenerator(function* (resolve) { var _ref = babelHelpers.asyncToGenerator(function* (resolve) {
console.log(_this); console.log(_this);
setTimeout(resolve, 1000); setTimeout(resolve, 1000);
}); });
return function (_x) { return function (_x) {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})()); })());
} }

View File

@ -1,5 +1,5 @@
let s = (() => { let s = (() => {
var ref = babelHelpers.asyncToGenerator(function* (x) { var _ref = babelHelpers.asyncToGenerator(function* (x) {
var _this = this, var _this = this,
_arguments = arguments; _arguments = arguments;
@ -8,9 +8,9 @@ let s = (() => {
} }
let t = (() => { let t = (() => {
var ref = babelHelpers.asyncToGenerator(function* (y, a) { var _ref2 = babelHelpers.asyncToGenerator(function* (y, a) {
let r = (() => { let r = (() => {
var ref = babelHelpers.asyncToGenerator(function* (z, b) { var _ref3 = babelHelpers.asyncToGenerator(function* (z, b) {
for (var _len2 = arguments.length, innerArgs = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { for (var _len2 = arguments.length, innerArgs = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
innerArgs[_key2 - 2] = arguments[_key2]; innerArgs[_key2 - 2] = arguments[_key2];
} }
@ -19,8 +19,9 @@ let s = (() => {
console.log(_this, innerArgs, _arguments); console.log(_this, innerArgs, _arguments);
return _this.x; return _this.x;
}); });
return function r(_x4, _x5) { return function r(_x4, _x5) {
return ref.apply(this, arguments); return _ref3.apply(this, arguments);
}; };
})(); })();
yield r(); yield r();
@ -28,15 +29,17 @@ let s = (() => {
console.log(_this, args, _arguments); console.log(_this, args, _arguments);
return _this.g(r); return _this.g(r);
}); });
return function t(_x2, _x3) { return function t(_x2, _x3) {
return ref.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
})(); })();
yield t(); yield t();
return this.h(t); return this.h(t);
}); });
return function s(_x) { return function s(_x) {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -1,8 +1,9 @@
var foo = (() => { var foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref = babelHelpers.asyncToGenerator(function* () {
var wat = yield bar(); var wat = yield bar();
}); });
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -1,10 +1,10 @@
var foo = (() => { var foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref = babelHelpers.asyncToGenerator(function* () {
console.log(bar); console.log(bar);
}); });
function bar() { function bar() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
} }
return bar; return bar;

View File

@ -1,6 +1,7 @@
let foo = (() => { let foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* (bar) {}); var _ref = babelHelpers.asyncToGenerator(function* (bar) {});
return function foo(_x) { return function foo(_x) {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -1,8 +1,9 @@
let foo = (() => { let foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref = babelHelpers.asyncToGenerator(function* () {
var wat = yield bar(); var wat = yield bar();
}); });
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
exports.foo = undefined; exports.foo = undefined;
let foo = exports.foo = (() => { let foo = exports.foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* () {}); var _ref = babelHelpers.asyncToGenerator(function* () {});
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
}); });
let foo = exports.foo = (() => { let foo = exports.foo = (() => {
var ref = babelHelpers.asyncToGenerator(function* () {}); var _ref = babelHelpers.asyncToGenerator(function* () {});
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -18,11 +18,12 @@ class Test {
console.log(_this2); console.log(_this2);
setTimeout((() => { setTimeout((() => {
var ref = babelHelpers.asyncToGenerator(function* (arg) { var _ref2 = babelHelpers.asyncToGenerator(function* (arg) {
console.log(_this2); console.log(_this2);
}); });
return function (_x) { return function (_x) {
return ref.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
})()); })());
})(); })();
@ -47,11 +48,12 @@ class Test {
console.log(_this4); console.log(_this4);
setTimeout((() => { setTimeout((() => {
var ref = babelHelpers.asyncToGenerator(function* (arg) { var _ref4 = babelHelpers.asyncToGenerator(function* (arg) {
console.log(_this4); console.log(_this4);
}); });
return function (_x2) { return function (_x2) {
return ref.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
})()); })());
})(); })();

View File

@ -1,10 +1,10 @@
import { coroutine as _coroutine } from "bluebird"; import { coroutine as _coroutine } from "bluebird";
var foo = (() => { var foo = (() => {
var ref = _coroutine(function* () { var _ref = _coroutine(function* () {
var wat = yield bar(); var wat = yield bar();
}); });
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -1,11 +1,11 @@
import { coroutine as _coroutine } from "bluebird"; import { coroutine as _coroutine } from "bluebird";
var foo = (() => { var foo = (() => {
var ref = _coroutine(function* () { var _ref = _coroutine(function* () {
console.log(bar); console.log(bar);
}); });
function bar() { function bar() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
} }
return bar; return bar;

View File

@ -1,11 +1,11 @@
import { coroutine as _coroutine } from "bluebird"; import { coroutine as _coroutine } from "bluebird";
let foo = (() => { let foo = (() => {
var ref = _coroutine(function* () { var _ref = _coroutine(function* () {
var wat = yield bar(); var wat = yield bar();
}); });
return function foo() { return function foo() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
})(); })();

View File

@ -1,15 +1,16 @@
var concat = function () { var concat = function () {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref = babelHelpers.asyncToGenerator(function* () {
var x = arguments.length <= 0 ? undefined : arguments[0]; var x = arguments.length <= 0 ? undefined : arguments[0];
var y = arguments.length <= 1 ? undefined : arguments[1]; var y = arguments.length <= 1 ? undefined : arguments[1];
}); });
return function concat() { return function concat() {
return ref.apply(this, arguments); return _ref.apply(this, arguments);
}; };
}(); }();
var x = function () { var x = function () {
var ref = babelHelpers.asyncToGenerator(function* () { var _ref2 = babelHelpers.asyncToGenerator(function* () {
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) { for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key]; rest[_key] = arguments[_key];
} }
@ -17,7 +18,8 @@ var x = function () {
if (noNeedToWork) return 0; if (noNeedToWork) return 0;
return rest; return rest;
}); });
return function x() { return function x() {
return ref.apply(this, arguments); return _ref2.apply(this, arguments);
}; };
}(); }();