Don't use _possibleConstructorReturn inside arrow functions (#6103)

Arrow functions can't be entrly skipped while traversing because this
references inside of them needs to be transformed, so I added a check
which prevents return statements inside arrow functions from being
saved for the transformation.

Fixes #5817 (regression)
This commit is contained in:
Nicolò Ribaudo
2017-08-14 17:11:05 +02:00
committed by Henry Zhu
parent 9e51038ad9
commit b84f8e9234
4 changed files with 51 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
class A extends B {
constructor() {
super();
this.arrow1 = (x) => { return x; };
this.arrow2 = (x) => x;
}
}

View File

@@ -0,0 +1,16 @@
// https://github.com/babel/babel/issues/5817
class Parent {}
class Table extends Parent {
constructor() {
super();
this.returnParam = (param) => {
return param;
}
}
}
const table = new Table();
assert(table.returnParam(false) === false);

View File

@@ -0,0 +1,24 @@
"use strict";
var A = function (_B) {
babelHelpers.inherits(A, _B);
function A() {
var _this;
babelHelpers.classCallCheck(this, A);
_this = babelHelpers.possibleConstructorReturn(this, (A.__proto__ || Object.getPrototypeOf(A)).call(this));
_this.arrow1 = function (x) {
return x;
};
_this.arrow2 = function (x) {
return x;
};
return _this;
}
return A;
}(B);