@@ -17175,7 +17175,8 @@ namespace ts {
17175
17175
17176
17176
let errorInfo: DiagnosticMessageChain | undefined;
17177
17177
let relatedInfo: [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] | undefined;
17178
- let maybeKeys: string[];
17178
+ let maybeKeyList: string[];
17179
+ let maybeKeySet: Set<string>;
17179
17180
let sourceStack: Type[];
17180
17181
let targetStack: Type[];
17181
17182
let maybeCount = 0;
@@ -18024,8 +18025,9 @@ namespace ts {
18024
18025
return entry & RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
18025
18026
}
18026
18027
}
18027
- if (!maybeKeys) {
18028
- maybeKeys = [];
18028
+ if (!maybeKeyList) {
18029
+ maybeKeyList = [];
18030
+ maybeKeySet = new Set<string>();
18029
18031
sourceStack = [];
18030
18032
targetStack = [];
18031
18033
}
@@ -18037,20 +18039,19 @@ namespace ts {
18037
18039
const index = length(id.slice(0, offset).match(/[-=]/g) || undefined);
18038
18040
return `=${index}`;
18039
18041
})).join(",");
18040
- for (let i = 0; i < maybeCount; i++ ) {
18042
+ if (maybeKeySet.has(id) || maybeKeySet.has(broadestEquivalentId) ) {
18041
18043
// If source and target are already being compared, consider them related with assumptions
18042
- if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
18043
- return Ternary.Maybe;
18044
- }
18044
+ return Ternary.Maybe;
18045
18045
}
18046
18046
if (depth === 100) {
18047
18047
overflow = true;
18048
18048
return Ternary.False;
18049
18049
}
18050
18050
}
18051
18051
const maybeStart = maybeCount;
18052
- maybeKeys [maybeCount] = id;
18052
+ maybeKeyList [maybeCount] = id;
18053
18053
maybeCount++;
18054
+ maybeKeySet.add(id);
18054
18055
sourceStack[depth] = source;
18055
18056
targetStack[depth] = target;
18056
18057
depth++;
@@ -18083,22 +18084,27 @@ namespace ts {
18083
18084
}
18084
18085
expandingFlags = saveExpandingFlags;
18085
18086
depth--;
18086
- if (result) {
18087
- if (result === Ternary.True || depth === 0) {
18088
- if (result === Ternary.True || result === Ternary.Maybe) {
18089
- // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
18090
- // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
18091
- for (let i = maybeStart; i < maybeCount; i++) {
18092
- relation.set(maybeKeys[i], RelationComparisonResult.Succeeded | propagatingVarianceFlags);
18093
- }
18087
+ if (result === Ternary.True || result === Ternary.False || depth === 0) {
18088
+ if (result === Ternary.True || result === Ternary.Maybe) {
18089
+ // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
18090
+ // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
18091
+ for (let i = maybeStart; i < maybeCount; i++) {
18092
+ relation.set(maybeKeyList[i], RelationComparisonResult.Succeeded | propagatingVarianceFlags);
18093
+ }
18094
+ }
18095
+ else if (result === Ternary.False) {
18096
+ // A false result goes straight into global cache (when something is false under
18097
+ // assumptions it will also be false without assumptions)
18098
+ relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags);
18099
+ }
18100
+ if (maybeStart === 0) {
18101
+ maybeKeySet.clear();
18102
+ }
18103
+ else {
18104
+ for (let i = maybeStart; i < maybeCount; i++) {
18105
+ maybeKeySet.delete(maybeKeyList[i]);
18094
18106
}
18095
- maybeCount = maybeStart;
18096
18107
}
18097
- }
18098
- else {
18099
- // A false result goes straight into global cache (when something is false under
18100
- // assumptions it will also be false without assumptions)
18101
- relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags);
18102
18108
maybeCount = maybeStart;
18103
18109
}
18104
18110
return result;
0 commit comments