Skip to content

Commit

Permalink
Convert base fields in relation comparison result to flags
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Aug 19, 2019
1 parent 8eb8f8d commit 0a555c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
18 changes: 8 additions & 10 deletions src/compiler/checker.ts
Expand Up @@ -12495,12 +12495,11 @@ namespace ts {
}
const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
const entry = enumRelation.get(id);
const relation = entry! & RelationComparisonResult.ResultMask;
if (entry !== undefined && !(relation === RelationComparisonResult.Failed && errorReporter)) {
return relation === RelationComparisonResult.Succeeded;
if (entry !== undefined && !(!(entry & RelationComparisonResult.Reported) && entry & RelationComparisonResult.Failed && errorReporter)) {
return !!(entry & RelationComparisonResult.Succeeded);
}
if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & SymbolFlags.RegularEnum) || !(targetSymbol.flags & SymbolFlags.RegularEnum)) {
enumRelation.set(id, RelationComparisonResult.FailedAndReported);
enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
return false;
}
const targetEnumType = getTypeOfSymbol(targetSymbol);
Expand All @@ -12511,7 +12510,7 @@ namespace ts {
if (errorReporter) {
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(property),
typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
enumRelation.set(id, RelationComparisonResult.FailedAndReported);
enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
}
else {
enumRelation.set(id, RelationComparisonResult.Failed);
Expand Down Expand Up @@ -12576,7 +12575,7 @@ namespace ts {
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
const related = relation.get(getRelationKey(source, target, relation));
if (related !== undefined) {
return (related & RelationComparisonResult.ResultMask) === RelationComparisonResult.Succeeded;
return !!(related & RelationComparisonResult.Succeeded);
}
}
if (source.flags & TypeFlags.StructuredOrInstantiable || target.flags & TypeFlags.StructuredOrInstantiable) {
Expand Down Expand Up @@ -13261,9 +13260,8 @@ namespace ts {
}
const id = getRelationKey(source, target, relation);
const entry = relation.get(id);
const related = entry! & RelationComparisonResult.ResultMask;
if (entry !== undefined) {
if (reportErrors && related === RelationComparisonResult.Failed) {
if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported)) {
// We are elaborating errors and the cached result is an unreported failure. The result will be reported
// as a failure, and should be updated as a reported failure by the bottom of this function.
}
Expand All @@ -13278,7 +13276,7 @@ namespace ts {
instantiateType(source, reportUnreliableMarkers);
}
}
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
return entry & RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
}
}
if (!maybeKeys) {
Expand Down Expand Up @@ -13334,7 +13332,7 @@ namespace ts {
else {
// A false result goes straight into global cache (when something is false under
// assumptions it will also be false without assumptions)
relation.set(id, (reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed) | propagatingVarianceFlags);
relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags);
maybeCount = maybeStart;
}
return result;
Expand Down
11 changes: 5 additions & 6 deletions src/compiler/types.ts
Expand Up @@ -614,13 +614,12 @@ namespace ts {

/* @internal */
export const enum RelationComparisonResult {
Succeeded = 1, // Should be truthy
Failed = 2,
FailedAndReported = 3,
ResultMask = 0x3,
Succeeded = 1 << 0, // Should be truthy
Failed = 1 << 1,
Reported = 1 << 2,

ReportsUnmeasurable = 1 << 2,
ReportsUnreliable = 1 << 3,
ReportsUnmeasurable = 1 << 3,
ReportsUnreliable = 1 << 4,
ReportsMask = ReportsUnmeasurable | ReportsUnreliable
}

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/user/create-react-app/create-react-app
2 changes: 1 addition & 1 deletion tests/cases/user/puppeteer/puppeteer
2 changes: 1 addition & 1 deletion tests/cases/user/webpack/webpack

0 comments on commit 0a555c7

Please sign in to comment.