From 3cc2032173b9162b28fc9bb41623a26faa10a565 Mon Sep 17 00:00:00 2001 From: JoostK Date: Thu, 5 Nov 2020 00:11:54 +0100 Subject: [PATCH] Ensure shared flow nodes are cached Flow nodes that optionally provide a flow type will delegate to their antecedent to determine a flow type using a loop in `getFlowTypeOfReference`. If these nodes are marked as shared then their result should be cached for future lookups, but the registration inside `getFlowTypeOfReference` did only consider the most-recently processed flow node. Any flow nodes up to that point that did not provide a type but were marked as shared would therefore not be cached at all. This commit keeps track of the first seen shared flow node and ensures that the result type is cached for that node. --- src/compiler/checker.ts | 27 +- ...rolFlowManyCallExpressionStatementsPerf.js | 125 +++++ ...owManyCallExpressionStatementsPerf.symbols | 292 +++++++++++ ...FlowManyCallExpressionStatementsPerf.types | 461 ++++++++++++++++++ ...rolFlowManyCallExpressionStatementsPerf.ts | 62 +++ 5 files changed, 962 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols create mode 100644 tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types create mode 100644 tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83bbb549a504b..e946b8dde0b8c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21673,6 +21673,12 @@ namespace ts { } } + function addSharedFlowType(flow: FlowNode, type: FlowType): void { + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, initialType = declaredType, flowContainer?: Node, couldBeUninitialized?: boolean) { let key: string | undefined; let isKeySet = false; @@ -21715,6 +21721,7 @@ namespace ts { return errorType; } flowDepth++; + let sharedFlow: FlowNode | undefined; while (true) { const flags = flow.flags; if (flags & FlowFlags.Shared) { @@ -21727,6 +21734,12 @@ namespace ts { return sharedFlowTypes[i]; } } + + // Keep track of the shared flow that is seen first to ensure that the + // computed type is saved in the shared flow type cache. + if (!sharedFlow) { + sharedFlow = flow; + } } let type: FlowType | undefined; if (flags & FlowFlags.Assignment) { @@ -21790,11 +21803,15 @@ namespace ts { // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & FlowFlags.Shared) { - // Record visited node and the associated type in the cache. - sharedFlowNodes[sharedFlowCount] = flow; - sharedFlowTypes[sharedFlowCount] = type; - sharedFlowCount++; + if (sharedFlow) { + // If the type for a shared flow was computed, record the associated type in the cache. + addSharedFlowType(sharedFlow, type); + + // If a shared flow was iterated over and the current flow is also shared, + // then also record the associated type with the current flow. + if (flow !== sharedFlow && flags & FlowFlags.Shared) { + addSharedFlowType(flow, type); + } } flowDepth--; return type; diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js new file mode 100644 index 0000000000000..67d874126ea07 --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.js @@ -0,0 +1,125 @@ +//// [controlFlowManyCallExpressionStatementsPerf.ts] +function test(x: boolean): boolean { return x; } + +let state = true; + +if (state) { + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); +} + +//// [controlFlowManyCallExpressionStatementsPerf.js] +function test(x) { return x; } +var state = true; +if (state) { + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); + test(state && state); +} diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols new file mode 100644 index 0000000000000..913da921c38dc --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.symbols @@ -0,0 +1,292 @@ +=== tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts === +function test(x: boolean): boolean { return x; } +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>x : Symbol(x, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 14)) +>x : Symbol(x, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 14)) + +let state = true; +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + +if (state) { +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) + + test(state as any && state); +>test : Symbol(test, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 0, 0)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +>state : Symbol(state, Decl(controlFlowManyCallExpressionStatementsPerf.ts, 2, 3)) +} diff --git a/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types new file mode 100644 index 0000000000000..f6241fb55e0d4 --- /dev/null +++ b/tests/baselines/reference/controlFlowManyCallExpressionStatementsPerf.types @@ -0,0 +1,461 @@ +=== tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts === +function test(x: boolean): boolean { return x; } +>test : (x: boolean) => boolean +>x : boolean +>x : boolean + +let state = true; +>state : boolean +>true : true + +if (state) { +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true + + test(state as any && state); +>test(state as any && state) : boolean +>test : (x: boolean) => boolean +>state as any && state : boolean +>state as any : any +>state : true +>state : true +} diff --git a/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts b/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts new file mode 100644 index 0000000000000..00805a485f618 --- /dev/null +++ b/tests/cases/compiler/controlFlowManyCallExpressionStatementsPerf.ts @@ -0,0 +1,62 @@ +function test(x: boolean): boolean { return x; } + +let state = true; + +if (state) { + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); + test(state as any && state); +} \ No newline at end of file