mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[TypeChecker] Produce a tailored diagnostic for for-in sequence failures
`for-in` "sequence" expression is required to conform to `Sequence`.
This commit is contained in:
@@ -3357,6 +3357,25 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
|
||||
formUnsolvedResult);
|
||||
}
|
||||
}
|
||||
|
||||
// If the left-hand side of a 'sequence element' constraint
|
||||
// is a dependent member type without any type variables it
|
||||
// means that conformance check has been "fixed".
|
||||
// Let's record other side of the conversion as a "hole"
|
||||
// to give the solver a chance to continue and avoid
|
||||
// producing diagnostics for both missing conformance and
|
||||
// invalid element type.
|
||||
if (shouldAttemptFixes()) {
|
||||
if (auto last = locator.last()) {
|
||||
if (last->is<LocatorPathElt::SequenceElementType>() &&
|
||||
desugar1->is<DependentMemberType>() &&
|
||||
!desugar1->hasTypeVariable()) {
|
||||
recordHole(typeVar2);
|
||||
return getTypeMatchSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return formUnsolvedResult();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user