Attach return control flow graph to contructor declaration nodes

This commit is contained in:
Anders Hejlsberg 2017-11-16 10:35:14 -08:00
parent 4b96edf72f
commit f1762a04ea
2 changed files with 7 additions and 1 deletions

View file

@ -514,8 +514,9 @@ namespace ts {
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
(<FlowStart>currentFlow).container = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
}
currentReturnTarget = undefined;
currentReturnTarget = node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined;
}
currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined;
currentBreakTarget = undefined;
currentContinueTarget = undefined;
activeLabels = undefined;
@ -535,6 +536,10 @@ namespace ts {
currentFlow = finishFlowLabel(currentReturnTarget);
}
else {
if (node.kind === SyntaxKind.Constructor) {
addAntecedent(currentReturnTarget, currentFlow);
(<ConstructorDeclaration>node).returnFlowNode = currentFlow;
}
currentFlow = saveCurrentFlow;
}
currentBreakTarget = saveBreakTarget;

View file

@ -929,6 +929,7 @@ namespace ts {
kind: SyntaxKind.Constructor;
parent?: ClassDeclaration | ClassExpression;
body?: FunctionBody;
returnFlowNode?: FlowNode;
}
/** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */