Skip to content

Commit 77eab82

Browse files
committed
in checkExpression(...), reset links.resolvedSignature to global resolvingSignature instead of undefined
1 parent 2317daa commit 77eab82

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/compiler/checker.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35162,6 +35162,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3516235162
}
3516335163
links.resolvedSignature = resolvingSignature;
3516435164
let result = resolveSignature(node, candidatesOutArray, checkMode || CheckMode.Normal);
35165+
/**
35166+
* #56013
35167+
* The following is an invariant condition beneath the above call to resolveSignature:
35168+
* - links.resolvedSignature is either the global constant readonly value `resolvingSignature`
35169+
* - or a calculated signature.
35170+
*/
35171+
Debug.assert(links.resolvedSignature);
35172+
3516535173
// When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call
3516635174
// resolution should be deferred.
3516735175
if (result !== resolvingSignature) {
@@ -35170,19 +35178,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3517035178
// since resolving such signature leads to resolving the potential outer signature, its arguments and thus the very same signature
3517135179
// it's possible that this inner resolution sets the resolvedSignature first.
3517235180
// In such a case we ignore the local result and reuse the correct one that was cached.
35173-
// [cph 56013] This is buggy - links.resolvedSignature could be `undefined`. Unfortunately flow did not warn us.
35174-
// if (links.resolvedSignature !== resolvingSignature) {
35175-
// result = links.resolvedSignature;
35176-
// }
35177-
if (links.resolvedSignature /* #56013 */ && links.resolvedSignature !== resolvingSignature) {
35181+
if (links.resolvedSignature !== resolvingSignature) {
3517835182
result = links.resolvedSignature;
3517935183
}
3518035184
// If signature resolution originated in control flow type analysis (for example to compute the
3518135185
// assigned type in a flow assignment) we don't cache the result as it may be based on temporary
3518235186
// types from the control flow analysis.
3518335187
links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
3518435188
}
35185-
Debug.assert(result); // [cph] #56013
3518635189
return result;
3518735190
}
3518835191

@@ -38954,7 +38957,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3895438957
let setOfNode: Set<Node> | undefined;
3895538958
if (chooseOverloadRecursionLevel >= 0 && (setOfNode = chooseOverloadFlushNodesSignaturesReq[chooseOverloadRecursionLevel])) {
3895638959
if (!setOfNode.has(node)) {
38957-
getNodeLinks(node).resolvedSignature = undefined;
38960+
/**
38961+
* #56013
38962+
* The following is an invariant condition beneath the above call to resolveSignature:
38963+
* - getNodeLinks(node).resolvedSignature is either the global constant readonly value `resolvingSignature`
38964+
* - or a calculated signature.
38965+
* Therefore resetting must set to `resolvingSignature` - it means "not yet calculated".
38966+
*/
38967+
getNodeLinks(node).resolvedSignature = resolvingSignature;
3895838968
setOfNode.add(node);
3895938969
}
3896038970
}

0 commit comments

Comments
 (0)