mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -13850,6 +13850,14 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
impact = 10;
|
||||
}
|
||||
|
||||
// Increase impact of invalid conversions to `Any` and `AnyHashable`
|
||||
// associated with collection elements (i.e. for-in sequence element)
|
||||
// because it means that other side is structurally incompatible.
|
||||
if (fix->getKind() == FixKind::IgnoreCollectionElementContextualMismatch) {
|
||||
if (type2->isAny() || type2->isAnyHashable())
|
||||
++impact;
|
||||
}
|
||||
|
||||
if (recordFix(fix, impact))
|
||||
return SolutionKind::Error;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user