Skip to content

Commit f1a2d75

Browse files
committed
[CSFix] Skip constrained erasure check (SE-0352) for sequence expressions
Just like `any Collection`, it should be possible to use `any Sequence` to iterate over.
1 parent 6a7a64a commit f1a2d75

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/Sema/CSFix.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2373,7 +2373,12 @@ bool AddExplicitExistentialCoercion::isRequired(
23732373
if (auto *anchor = getAsExpr(locator.getAnchor())) {
23742374
// If this is erasure related to `Self`, let's look through
23752375
// the call, if any.
2376-
if (isa<UnresolvedDotExpr>(anchor)) {
2376+
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(anchor)) {
2377+
// If this is an implicit `makeIterator` call, let's skip the check.
2378+
if (UDE->isImplicit() &&
2379+
cs.getContextualTypePurpose(UDE->getBase()) == CTP_ForEachSequence)
2380+
return false;
2381+
23772382
auto parentExpr = cs.getParentExpr(anchor);
23782383
if (parentExpr && isa<CallExpr>(parentExpr))
23792384
anchor = parentExpr;

0 commit comments

Comments
 (0)