mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -478,7 +478,7 @@ swift::FragileFunctionKindRequest::evaluate(Evaluator &evaluator,
|
||||
/*allowUsableFromInline=*/true};
|
||||
}
|
||||
|
||||
if (AFD->getAttrs().hasAttribute<BackDeployedAttr>()) {
|
||||
if (AFD->isBackDeployed(context->getASTContext())) {
|
||||
return {FragileFunctionKind::BackDeploy,
|
||||
/*allowUsableFromInline=*/true};
|
||||
}
|
||||
@@ -495,7 +495,7 @@ swift::FragileFunctionKindRequest::evaluate(Evaluator &evaluator,
|
||||
return {FragileFunctionKind::AlwaysEmitIntoClient,
|
||||
/*allowUsableFromInline=*/true};
|
||||
}
|
||||
if (storage->getAttrs().hasAttribute<BackDeployedAttr>()) {
|
||||
if (storage->isBackDeployed(context->getASTContext())) {
|
||||
return {FragileFunctionKind::BackDeploy,
|
||||
/*allowUsableFromInline=*/true};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user