mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Unsafe] Teach for..in loops to let the sequence's 'unsafe' cover next()
Warnings about unsafe uses due to an @unsafe IteratorProtocol conformance (for the implicit call to next()) could not be silenced. Follow the same path we did for the Sequence conformance (and makeIterator() call) by associating it with the `unsafe` on the sequence argument. This isn't the only solution here, but it's a reasonable one.
This commit is contained in:
@@ -3854,6 +3854,12 @@ generateForEachStmtConstraints(ConstraintSystem &cs, DeclContext *dc,
|
||||
AwaitExpr::createImplicit(ctx, nextCall->getLoc(), nextCall);
|
||||
}
|
||||
|
||||
// Wrap the 'next' call in 'unsafe', if there is one.
|
||||
if (unsafeExpr) {
|
||||
nextCall = new (ctx) UnsafeExpr(unsafeExpr->getLoc(), nextCall, Type(),
|
||||
/*implicit=*/true);
|
||||
}
|
||||
|
||||
// The iterator type must conform to IteratorProtocol.
|
||||
{
|
||||
ProtocolDecl *iteratorProto = TypeChecker::getProtocol(
|
||||
|
||||
Reference in New Issue
Block a user