Skip to content

Commit cf5d41c

Browse files
committed
[CSSimplify] Increase contextual element mismatch impact when related to Any{Hashable}
Impact is higher in this case because it means that other collection or a pattern (in case of for-in loop) is structurally incompatible with collection's element type.
1 parent 3c0401c commit cf5d41c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13850,6 +13850,14 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1385013850
impact = 10;
1385113851
}
1385213852

13853+
// Increase impact of invalid conversions to `Any` and `AnyHashable`
13854+
// associated with collection elements (i.e. for-in sequence element)
13855+
// because it means that other side is structurally incompatible.
13856+
if (fix->getKind() == FixKind::IgnoreCollectionElementContextualMismatch) {
13857+
if (type2->isAny() || type2->isAnyHashable())
13858+
++impact;
13859+
}
13860+
1385313861
if (recordFix(fix, impact))
1385413862
return SolutionKind::Error;
1385513863

0 commit comments

Comments
 (0)