[CoroutineAccessors] Only reference when available

Don't bind references to storage to use (new ABI) coroutine accessors
unless they're guaranteed to be available.  For example, when building
against a resilient module that has coroutine accessors, they can only
be used if the deployment target is >= the version of Swift that
includes the feature.

rdar://148783895
This commit is contained in:
Nate Chandler
2025-04-15 17:52:04 -07:00
parent 85860f6960
commit de1d5ae894
10 changed files with 487 additions and 41 deletions

View File

@@ -3323,11 +3323,13 @@ static bool isBorrowableSubject(SILGenFunction &SGF,
if (!storage) {
return false;
}
auto pair = std::make_pair<>(subjectExpr->getSourceRange(), SGF.FunctionDC);
// Check the access strategy used to read the storage.
auto strategy =
storage->getAccessStrategy(access, AccessKind::Read, SGF.SGM.SwiftModule,
SGF.F.getResilienceExpansion(),
SGF.F.getResilienceExpansion(), pair,
/*useOldABI=*/false);
switch (strategy.getKind()) {