@@ -4413,6 +4413,43 @@ bool swift::checkSendableConformance(
4413
4413
return checkSendableInstanceStorage (nominal, conformanceDC, check);
4414
4414
}
4415
4415
4416
+ // / Add "unavailable" attributes to the given extension.
4417
+ static void addUnavailableAttrs (ExtensionDecl *ext, NominalTypeDecl *nominal) {
4418
+ ASTContext &ctx = nominal->getASTContext ();
4419
+ llvm::VersionTuple noVersion;
4420
+
4421
+ // Add platform-version-specific @available attributes.
4422
+ for (auto available : nominal->getAttrs ().getAttributes <AvailableAttr>()) {
4423
+ if (available->Platform == PlatformKind::none)
4424
+ continue ;
4425
+
4426
+ auto attr = new (ctx) AvailableAttr (
4427
+ SourceLoc (), SourceRange (),
4428
+ available->Platform ,
4429
+ available->Message ,
4430
+ " " , nullptr ,
4431
+ available->Introduced .getValueOr (noVersion), SourceRange (),
4432
+ available->Deprecated .getValueOr (noVersion), SourceRange (),
4433
+ available->Obsoleted .getValueOr (noVersion), SourceRange (),
4434
+ PlatformAgnosticAvailabilityKind::Unavailable,
4435
+ /* implicit=*/ true ,
4436
+ available->IsSPI );
4437
+ ext->getAttrs ().add (attr);
4438
+ }
4439
+
4440
+ // Add the blanket "unavailable".
4441
+
4442
+ auto attr = new (ctx) AvailableAttr (SourceLoc (), SourceRange (),
4443
+ PlatformKind::none, " " , " " , nullptr ,
4444
+ noVersion, SourceRange (),
4445
+ noVersion, SourceRange (),
4446
+ noVersion, SourceRange (),
4447
+ PlatformAgnosticAvailabilityKind::Unavailable,
4448
+ false ,
4449
+ false );
4450
+ ext->getAttrs ().add (attr);
4451
+ }
4452
+
4416
4453
ProtocolConformance *GetImplicitSendableRequest::evaluate (
4417
4454
Evaluator &evaluator, NominalTypeDecl *nominal) const {
4418
4455
// Protocols never get implicit Sendable conformances.
@@ -4468,16 +4505,6 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
4468
4505
-> NormalProtocolConformance * {
4469
4506
DeclContext *conformanceDC = nominal;
4470
4507
if (attrMakingUnavailable) {
4471
- llvm::VersionTuple NoVersion;
4472
- auto attr = new (ctx) AvailableAttr (SourceLoc (), SourceRange (),
4473
- PlatformKind::none, " " , " " , nullptr ,
4474
- NoVersion, SourceRange (),
4475
- NoVersion, SourceRange (),
4476
- NoVersion, SourceRange (),
4477
- PlatformAgnosticAvailabilityKind::Unavailable,
4478
- false ,
4479
- false );
4480
-
4481
4508
// Conformance availability is currently tied to the declaring extension.
4482
4509
// FIXME: This is a hack--we should give conformances real availability.
4483
4510
auto inherits = ctx.AllocateCopy (makeArrayRef (
@@ -4490,7 +4517,7 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
4490
4517
nominal->getModuleScopeContext (),
4491
4518
nullptr );
4492
4519
extension->setImplicit ();
4493
- extension-> getAttrs (). add (attr );
4520
+ addUnavailableAttrs (extension, nominal );
4494
4521
4495
4522
ctx.evaluator .cacheOutput (ExtendedTypeRequest{extension},
4496
4523
nominal->getDeclaredType ());
0 commit comments