@@ -35162,6 +35162,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
35162
35162
}
35163
35163
links.resolvedSignature = resolvingSignature;
35164
35164
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
+
35165
35173
// When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call
35166
35174
// resolution should be deferred.
35167
35175
if (result !== resolvingSignature) {
@@ -35170,19 +35178,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
35170
35178
// since resolving such signature leads to resolving the potential outer signature, its arguments and thus the very same signature
35171
35179
// it's possible that this inner resolution sets the resolvedSignature first.
35172
35180
// 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) {
35178
35182
result = links.resolvedSignature;
35179
35183
}
35180
35184
// If signature resolution originated in control flow type analysis (for example to compute the
35181
35185
// assigned type in a flow assignment) we don't cache the result as it may be based on temporary
35182
35186
// types from the control flow analysis.
35183
35187
links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
35184
35188
}
35185
- Debug.assert(result); // [cph] #56013
35186
35189
return result;
35187
35190
}
35188
35191
@@ -38954,7 +38957,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
38954
38957
let setOfNode: Set<Node> | undefined;
38955
38958
if (chooseOverloadRecursionLevel >= 0 && (setOfNode = chooseOverloadFlushNodesSignaturesReq[chooseOverloadRecursionLevel])) {
38956
38959
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;
38958
38968
setOfNode.add(node);
38959
38969
}
38960
38970
}
0 commit comments