@@ -4420,6 +4420,43 @@ bool swift::checkSendableConformance(
4420
4420
return checkSendableInstanceStorage (nominal, conformanceDC, check);
4421
4421
}
4422
4422
4423
+ // / Add "unavailable" attributes to the given extension.
4424
+ static void addUnavailableAttrs (ExtensionDecl *ext, NominalTypeDecl *nominal) {
4425
+ ASTContext &ctx = nominal->getASTContext ();
4426
+ llvm::VersionTuple noVersion;
4427
+
4428
+ // Add platform-version-specific @available attributes.
4429
+ for (auto available : nominal->getAttrs ().getAttributes <AvailableAttr>()) {
4430
+ if (available->Platform == PlatformKind::none)
4431
+ continue ;
4432
+
4433
+ auto attr = new (ctx) AvailableAttr (
4434
+ SourceLoc (), SourceRange (),
4435
+ available->Platform ,
4436
+ available->Message ,
4437
+ " " , nullptr ,
4438
+ available->Introduced .getValueOr (noVersion), SourceRange (),
4439
+ available->Deprecated .getValueOr (noVersion), SourceRange (),
4440
+ available->Obsoleted .getValueOr (noVersion), SourceRange (),
4441
+ PlatformAgnosticAvailabilityKind::Unavailable,
4442
+ /* implicit=*/ true ,
4443
+ available->IsSPI );
4444
+ ext->getAttrs ().add (attr);
4445
+ }
4446
+
4447
+ // Add the blanket "unavailable".
4448
+
4449
+ auto attr = new (ctx) AvailableAttr (SourceLoc (), SourceRange (),
4450
+ PlatformKind::none, " " , " " , nullptr ,
4451
+ noVersion, SourceRange (),
4452
+ noVersion, SourceRange (),
4453
+ noVersion, SourceRange (),
4454
+ PlatformAgnosticAvailabilityKind::Unavailable,
4455
+ false ,
4456
+ false );
4457
+ ext->getAttrs ().add (attr);
4458
+ }
4459
+
4423
4460
ProtocolConformance *GetImplicitSendableRequest::evaluate (
4424
4461
Evaluator &evaluator, NominalTypeDecl *nominal) const {
4425
4462
// Protocols never get implicit Sendable conformances.
@@ -4475,16 +4512,6 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
4475
4512
-> NormalProtocolConformance * {
4476
4513
DeclContext *conformanceDC = nominal;
4477
4514
if (attrMakingUnavailable) {
4478
- llvm::VersionTuple NoVersion;
4479
- auto attr = new (ctx) AvailableAttr (SourceLoc (), SourceRange (),
4480
- PlatformKind::none, " " , " " , nullptr ,
4481
- NoVersion, SourceRange (),
4482
- NoVersion, SourceRange (),
4483
- NoVersion, SourceRange (),
4484
- PlatformAgnosticAvailabilityKind::Unavailable,
4485
- false ,
4486
- false );
4487
-
4488
4515
// Conformance availability is currently tied to the declaring extension.
4489
4516
// FIXME: This is a hack--we should give conformances real availability.
4490
4517
auto inherits = ctx.AllocateCopy (makeArrayRef (
@@ -4497,7 +4524,7 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
4497
4524
nominal->getModuleScopeContext (),
4498
4525
nullptr );
4499
4526
extension->setImplicit ();
4500
- extension-> getAttrs (). add (attr );
4527
+ addUnavailableAttrs (extension, nominal );
4501
4528
4502
4529
ctx.evaluator .cacheOutput (ExtendedTypeRequest{extension},
4503
4530
nominal->getDeclaredType ());
0 commit comments