Skip to content

Commit 0a555c7

Browse files
committed
Convert base fields in relation comparison result to flags
1 parent 8eb8f8d commit 0a555c7

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12495,12 +12495,11 @@ namespace ts {
1249512495
}
1249612496
const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
1249712497
const entry = enumRelation.get(id);
12498-
const relation = entry! & RelationComparisonResult.ResultMask;
12499-
if (entry !== undefined && !(relation === RelationComparisonResult.Failed && errorReporter)) {
12500-
return relation === RelationComparisonResult.Succeeded;
12498+
if (entry !== undefined && !(!(entry & RelationComparisonResult.Reported) && entry & RelationComparisonResult.Failed && errorReporter)) {
12499+
return !!(entry & RelationComparisonResult.Succeeded);
1250112500
}
1250212501
if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) {
12503-
enumRelation.set(id, RelationComparisonResult.FailedAndReported);
12502+
enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
1250412503
return false;
1250512504
}
1250612505
const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -12511,7 +12510,7 @@ namespace ts {
1251112510
if (errorReporter) {
1251212511
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(property),
1251312512
typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
12514-
enumRelation.set(id, RelationComparisonResult.FailedAndReported);
12513+
enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
1251512514
}
1251612515
else {
1251712516
enumRelation.set(id, RelationComparisonResult.Failed);
@@ -12576,7 +12575,7 @@ namespace ts {
1257612575
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
1257712576
const related = relation.get(getRelationKey(source, target, relation));
1257812577
if (related !== undefined) {
12579-
return (related & RelationComparisonResult.ResultMask) === RelationComparisonResult.Succeeded;
12578+
return !!(related & RelationComparisonResult.Succeeded);
1258012579
}
1258112580
}
1258212581
if (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable) {
@@ -13261,9 +13260,8 @@ namespace ts {
1326113260
}
1326213261
const id = getRelationKey(source, target, relation);
1326313262
const entry = relation.get(id);
13264-
const related = entry! & RelationComparisonResult.ResultMask;
1326513263
if (entry !== undefined) {
13266-
if (reportErrors && related === RelationComparisonResult.Failed) {
13264+
if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported)) {
1326713265
// We are elaborating errors and the cached result is an unreported failure. The result will be reported
1326813266
// as a failure, and should be updated as a reported failure by the bottom of this function.
1326913267
}
@@ -13278,7 +13276,7 @@ namespace ts {
1327813276
instantiateType(source, reportUnreliableMarkers);
1327913277
}
1328013278
}
13281-
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
13279+
return entry & RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
1328213280
}
1328313281
}
1328413282
if (!maybeKeys) {
@@ -13334,7 +13332,7 @@ namespace ts {
1333413332
else {
1333513333
// A false result goes straight into global cache (when something is false under
1333613334
// assumptions it will also be false without assumptions)
13337-
relation.set(id, (reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed) | propagatingVarianceFlags);
13335+
relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags);
1333813336
maybeCount = maybeStart;
1333913337
}
1334013338
return result;

src/compiler/types.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,12 @@ namespace ts {
614614

615615
/* @internal */
616616
export const enum RelationComparisonResult {
617-
Succeeded = 1, // Should be truthy
618-
Failed = 2,
619-
FailedAndReported = 3,
620-
ResultMask = 0x3,
617+
Succeeded = 1 << 0, // Should be truthy
618+
Failed = 1 << 1,
619+
Reported = 1 << 2,
621620

622-
ReportsUnmeasurable = 1 << 2,
623-
ReportsUnreliable = 1 << 3,
621+
ReportsUnmeasurable = 1 << 3,
622+
ReportsUnreliable = 1 << 4,
624623
ReportsMask = ReportsUnmeasurable | ReportsUnreliable
625624
}
626625

0 commit comments

Comments
 (0)