From f1762a04ea736565ae0d988cc7a39de9e9d53d4b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 16 Nov 2017 10:35:14 -0800 Subject: [PATCH] Attach return control flow graph to contructor declaration nodes --- src/compiler/binder.ts | 7 ++++++- src/compiler/types.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a0146740678..076abcba81b 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -514,8 +514,9 @@ namespace ts { if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) { (currentFlow).container = 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); + (node).returnFlowNode = currentFlow; + } currentFlow = saveCurrentFlow; } currentBreakTarget = saveBreakTarget; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3141e3f22d9..32d6dc72fb9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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. */