@@ -469,25 +469,10 @@ namespace ts {
469
469
};
470
470
471
471
const subtypeRelation = createMap<RelationComparisonResult>();
472
- const subtypeRelationErrors = createMap<DiagnosticMessageChain>();
473
472
const assignableRelation = createMap<RelationComparisonResult>();
474
- const assignableRelationErrors = createMap<DiagnosticMessageChain>();
475
473
const comparableRelation = createMap<RelationComparisonResult>();
476
- const comparableRelationErrors = createMap<DiagnosticMessageChain>();
477
474
const identityRelation = createMap<RelationComparisonResult>();
478
- const identityRelationErrors = createMap<DiagnosticMessageChain>();
479
475
const enumRelation = createMap<boolean>();
480
- const enumRelationErrors = createMap<DiagnosticMessageChain>();
481
-
482
- function getErrorCache(relation: Map<RelationComparisonResult> | Map<boolean>) {
483
- switch (true) {
484
- case relation === subtypeRelation: return subtypeRelationErrors;
485
- case relation === assignableRelation: return assignableRelationErrors;
486
- case relation === comparableRelation: return comparableRelationErrors;
487
- case relation === identityRelation: return identityRelationErrors;
488
- case relation === enumRelation: return enumRelationErrors;
489
- }
490
- }
491
476
492
477
// This is for caching the result of getSymbolDisplayBuilder. Do not access directly.
493
478
let _displayBuilder: SymbolDisplayBuilder;
@@ -8933,17 +8918,6 @@ namespace ts {
8933
8918
* * Ternary.False if they are not related.
8934
8919
*/
8935
8920
function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary {
8936
- const comparisonId = comparisonTypeId(source, target);
8937
- const cachedResult = fetchRelationResult(comparisonId);
8938
- if (cachedResult !== undefined) {
8939
- if (reportErrors && cachedResult === Ternary.False) {
8940
- const cachedChain = getErrorCache(relation).get(comparisonId);
8941
- if (cachedChain) {
8942
- errorInfo = concatenateDiagnosticMessageChains(errorInfo, cachedChain);
8943
- }
8944
- }
8945
- return cachedResult;
8946
- }
8947
8921
if (source.flags & TypeFlags.StringOrNumberLiteral && source.flags & TypeFlags.FreshLiteral) {
8948
8922
source = (<LiteralType>source).regularType;
8949
8923
}
@@ -9054,14 +9028,6 @@ namespace ts {
9054
9028
}
9055
9029
reportRelationError(headMessage, source, target);
9056
9030
}
9057
-
9058
- if (fetchRelationResult(comparisonId) === undefined) {
9059
- relation.set(comparisonId, result ? RelationComparisonResult.Succeeded : reportErrors ? RelationComparisonResult.FailedAndReported : RelationComparisonResult.Failed);
9060
- if (reportErrors && errorInfo) {
9061
- getErrorCache(relation).set(comparisonId, errorInfo);
9062
- }
9063
- }
9064
-
9065
9031
return result;
9066
9032
}
9067
9033
@@ -9224,24 +9190,6 @@ namespace ts {
9224
9190
return result;
9225
9191
}
9226
9192
9227
- function comparisonTypeId(source: Type, target: Type) {
9228
- return relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
9229
- }
9230
-
9231
- function fetchRelationResult(id: string, reportErrors?: boolean): Ternary | undefined {
9232
- const related = relation.get(id);
9233
- if (related !== undefined) {
9234
- if (reportErrors && related === RelationComparisonResult.Failed) {
9235
- // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported
9236
- // failure and continue computing the relation such that errors get reported.
9237
- relation.set(id, RelationComparisonResult.FailedAndReported);
9238
- }
9239
- else {
9240
- return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
9241
- }
9242
- }
9243
- }
9244
-
9245
9193
// Determine if possibly recursive types are related. First, check if the result is already available in the global cache.
9246
9194
// Second, check if we have already started a comparison of the given two types in which case we assume the result to be true.
9247
9195
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
@@ -9260,7 +9208,7 @@ namespace ts {
9260
9208
// this is a copy of the normal code! It can probably be merged somehow.
9261
9209
const src = (source as TypeReference).target;
9262
9210
const trg = (target as TypeReference).target;
9263
- const id = comparisonTypeId( src, trg) ;
9211
+ const id = relation !== identityRelation || src.id < trg.id ? src.id + "," + trg.id : trg.id + "," + src.id ;
9264
9212
if (!maybeReferenceKeys) {
9265
9213
maybeReferenceKeys = [];
9266
9214
}
@@ -9275,11 +9223,19 @@ namespace ts {
9275
9223
maybeReferenceCount++;
9276
9224
}
9277
9225
9278
- const id = comparisonTypeId(source, target);
9279
- const cachedResult = fetchRelationResult(id);
9280
- if (cachedResult !== undefined) {
9281
- return cachedResult;
9226
+ const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
9227
+ const related = relation.get(id);
9228
+ if (related !== undefined) {
9229
+ if (reportErrors && related === RelationComparisonResult.Failed) {
9230
+ // We are elaborating errors and the cached result is an unreported failure. Record the result as a reported
9231
+ // failure and continue computing the relation such that errors get reported.
9232
+ relation.set(id, RelationComparisonResult.FailedAndReported);
9233
+ }
9234
+ else {
9235
+ return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
9236
+ }
9282
9237
}
9238
+
9283
9239
if (!maybeKeys) {
9284
9240
maybeKeys = [];
9285
9241
sourceStack = [];
0 commit comments