mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Propegate variance a bit more selectively
This commit is contained in:
+12
-9
@@ -12981,13 +12981,16 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function propegateSidebandVarianceFlags(variances: VarianceFlags[]) {
|
||||
function propegateSidebandVarianceFlags(typeArguments: readonly Type[], variances: VarianceFlags[]) {
|
||||
if (outofbandVarianceMarkerHandler) {
|
||||
if (some(variances, v => !!(v & VarianceFlags.Unmeasurable))) {
|
||||
outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false);
|
||||
}
|
||||
if (some(variances, v => !!(v & VarianceFlags.Unreliable))) {
|
||||
outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true);
|
||||
for (let i = 0; i < variances.length; i++) {
|
||||
const v = variances[i];
|
||||
if (v & VarianceFlags.Unmeasurable) {
|
||||
instantiateType(typeArguments[i], reportUnmeasurableMarkers);
|
||||
}
|
||||
if (v & VarianceFlags.Unreliable) {
|
||||
instantiateType(typeArguments[i], reportUnreliableMarkers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13013,10 +13016,10 @@ namespace ts {
|
||||
// We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component
|
||||
if (source.flags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol &&
|
||||
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
propegateSidebandVarianceFlags(getAliasVariances(source.aliasSymbol));
|
||||
propegateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
|
||||
}
|
||||
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||
propegateSidebandVarianceFlags(getVariances((<TypeReference>source).target));
|
||||
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target && length((<TypeReference>source).typeArguments)) {
|
||||
propegateSidebandVarianceFlags((<TypeReference>source).typeArguments!, getVariances((<TypeReference>source).target));
|
||||
}
|
||||
}
|
||||
return related === RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
|
||||
|
||||
Reference in New Issue
Block a user