AST: Only treat @backDeployed functions as fragile on platforms with an active attribute.

Previously, typechecking and SILGen would treat a function body as fragile as long as the declaration had a `@backDeployed` attribute, regardless of the platform specified by the attribute. This was overly conservative since back deployed functions are only emitted into the client on specific platforms. Now a `@backDeployed` function can reference non-`public` declarations on the platforms it is resilient on:

```
@backDeployed(before: iOS 15)
public func foo() {
  #if os(iOS)
  // Fragile; this code may be emitted into the client.
  #else
  // Resilient; this code won't ever be exposed to clients.
  #endif
}
```

Resolves rdar://105298520
This commit is contained in:
Allan Shortlidge
2023-02-21 22:42:34 -08:00
parent 11c32fa943
commit f1a8740ba5
11 changed files with 102 additions and 44 deletions

View File

@@ -955,7 +955,7 @@ bool SILDeclRef::isBackDeployed() const {
auto *decl = getDecl();
if (auto afd = dyn_cast<AbstractFunctionDecl>(decl))
return afd->isBackDeployed();
return afd->isBackDeployed(getASTContext());
return false;
}