Merge pull request #3138 from loganfsmyth/class-rename-failure-T2494

Skip name inference on hard-to-replace classes - fixes T2494
This commit is contained in:
James Kyle
2015-12-05 20:58:37 -08:00
3 changed files with 22 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ let buildPropertyMethodAssignmentWrapper = template(`
})(FUNCTION)
`);
let buldGeneratorPropertyMethodAssignmentWrapper = template(`
let buildGeneratorPropertyMethodAssignmentWrapper = template(`
(function (FUNCTION_KEY) {
function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments);
@@ -51,9 +51,12 @@ function wrap(state, method, id, scope) {
// we can just munge the local binding
scope.rename(id.name);
} else {
// we don't currently support wrapping class expressions
if (!t.isFunction(method)) return;
// need to add a wrapper since we can't change the references
let build = buildPropertyMethodAssignmentWrapper;
if (method.generator) build = buldGeneratorPropertyMethodAssignmentWrapper;
if (method.generator) build = buildGeneratorPropertyMethodAssignmentWrapper;
let template = build({
FUNCTION: method,
FUNCTION_ID: id,

View File

@@ -0,0 +1,3 @@
var x = {
Foo: class extends Foo {}
};

View File

@@ -0,0 +1,14 @@
"use strict";
var x = {
Foo: (function (_Foo) {
babelHelpers.inherits(_class, _Foo);
function _class() {
babelHelpers.classCallCheck(this, _class);
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments));
}
return _class;
})(Foo)
};