mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #70635 from DougGregor/async-sequence-typed-throws
Adopt typed throws in AsyncIteratorProtocol and AsyncSequence
This commit is contained in:
@@ -10705,15 +10705,16 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
|
||||
|
||||
// Handle `next` reference.
|
||||
if (getContextualTypePurpose(baseExpr) == CTP_ForEachSequence &&
|
||||
isRefTo(memberRef, ctx.Id_next, /*labels=*/{})) {
|
||||
(isRefTo(memberRef, ctx.Id_next, /*labels=*/{}) ||
|
||||
isRefTo(memberRef, ctx.Id_next, /*labels=*/{StringRef()}))) {
|
||||
auto *iteratorProto = cast<ProtocolDecl>(
|
||||
getContextualType(baseExpr, /*forConstraint=*/false)
|
||||
->getAnyNominal());
|
||||
bool isAsync = iteratorProto->getKnownProtocolKind() ==
|
||||
KnownProtocolKind::AsyncIteratorProtocol;
|
||||
|
||||
auto *next =
|
||||
isAsync ? ctx.getAsyncIteratorNext() : ctx.getIteratorNext();
|
||||
auto loc = locator->getAnchor().getStartLoc();
|
||||
auto *next = TypeChecker::getForEachIteratorNextFunction(DC, loc, isAsync);
|
||||
|
||||
return simplifyValueWitnessConstraint(
|
||||
ConstraintKind::ValueWitness, baseTy, next, memberTy, useDC,
|
||||
@@ -10931,7 +10932,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
|
||||
if (auto *base = dyn_cast<DeclRefExpr>(UDE->getBase())) {
|
||||
if (auto var = dyn_cast_or_null<VarDecl>(base->getDecl())) {
|
||||
if (var->getNameStr().contains("$generator") &&
|
||||
UDE->getName().getBaseIdentifier() == Context.Id_next)
|
||||
(UDE->getName().getBaseIdentifier() == Context.Id_next))
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user