@@ -287,6 +287,10 @@ struct ASTContext::Implementation {
287287 // / The declaration of 'AsyncIteratorProtocol.next()'.
288288 FuncDecl *AsyncIteratorNext = nullptr ;
289289
290+ // / The declaration of 'AsyncIteratorProtocol.next(_:)' that takes
291+ // / an actor isolation.
292+ FuncDecl *AsyncIteratorNextIsolated = nullptr ;
293+
290294 // / The declaration of Swift.Optional<T>.Some.
291295 EnumElementDecl *OptionalSomeDecl = nullptr ;
292296
@@ -948,21 +952,48 @@ FuncDecl *ASTContext::getIteratorNext() const {
948952 return nullptr ;
949953}
950954
955+ static std::pair<FuncDecl *, FuncDecl *>
956+ getAsyncIteratorNextRequirements (const ASTContext &ctx) {
957+ auto proto = ctx.getProtocol (KnownProtocolKind::AsyncIteratorProtocol);
958+ if (!proto)
959+ return { nullptr , nullptr };
960+
961+ FuncDecl *next = nullptr ;
962+ FuncDecl *nextThrowing = nullptr ;
963+ for (auto result : proto->lookupDirect (ctx.Id_next )) {
964+ if (result->getDeclContext () != proto)
965+ continue ;
966+
967+ if (auto func = dyn_cast<FuncDecl>(result)) {
968+ switch (func->getParameters ()->size ()) {
969+ case 0 : next = func; break ;
970+ case 1 : nextThrowing = func; break ;
971+ default : break ;
972+ }
973+ }
974+ }
975+
976+ return { next, nextThrowing };
977+ }
978+
951979FuncDecl *ASTContext::getAsyncIteratorNext () const {
952980 if (getImpl ().AsyncIteratorNext ) {
953981 return getImpl ().AsyncIteratorNext ;
954982 }
955983
956- auto proto = getProtocol (KnownProtocolKind::AsyncIteratorProtocol);
957- if (!proto)
958- return nullptr ;
984+ auto next = getAsyncIteratorNextRequirements (*this ).first ;
985+ getImpl ().AsyncIteratorNext = next;
986+ return next;
987+ }
959988
960- if ( auto *func = lookupRequirement (proto, Id_next)) {
961- getImpl ().AsyncIteratorNext = func;
962- return func ;
989+ FuncDecl * ASTContext::getAsyncIteratorNextIsolated () const {
990+ if ( getImpl ().AsyncIteratorNextIsolated ) {
991+ return getImpl (). AsyncIteratorNextIsolated ;
963992 }
964993
965- return nullptr ;
994+ auto nextThrowing = getAsyncIteratorNextRequirements (*this ).second ;
995+ getImpl ().AsyncIteratorNextIsolated = nextThrowing;
996+ return nextThrowing;
966997}
967998
968999namespace {
0 commit comments