clean up shadow functions findParent logic - fixes #1846

This commit is contained in:
Sebastian McKenzie 2015-06-26 11:34:13 +01:00
parent 98f28b8e89
commit 41cf942391

View File

@ -8,27 +8,26 @@ function remap(path, key, create) {
// ensure that we're shadowed
if (!path.inShadow()) return;
var shadowed = path.node._shadowedFunctionLiteral;
var shadowFunction = path.node._shadowedFunctionLiteral;
var currentFunction;
var fnPath = path.findParent(function (path) {
if (shadowed) {
// only match our shadowed function parent
if (path === shadowed) {
// found our target reference function
currentFunction = path;
return true;
} else {
return false;
}
} else if (path.isFunction() || path.isProgram()) {
// catch current function in case this is the shadowed one
if (path.isProgram() || path.isFunction()) {
// catch current function in case this is the shadowed one and we can ignore it
if (!currentFunction) currentFunction = path;
return !path.is("shadow");
} else {
return false;
}
if (path.isProgram()) {
return true;
} else if (path.isFunction()) {
if (shadowFunction) {
return path === shadowFunction;
} else {
return !path.is("shadow");
}
}
return false;
});
// no point in realiasing if we're in this function