Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Attach return control flow graph to contructor declaration nodes
  • Loading branch information
ahejlsberg committed Nov 16, 2017
commit f1762a04ea736565ae0d988cc7a39de9e9d53d4b
7 changes: 6 additions & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down