@@ -4413,6 +4413,43 @@ bool swift::checkSendableConformance(
44134413 return checkSendableInstanceStorage (nominal, conformanceDC, check);
44144414}
44154415
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+
44164453ProtocolConformance *GetImplicitSendableRequest::evaluate (
44174454 Evaluator &evaluator, NominalTypeDecl *nominal) const {
44184455 // Protocols never get implicit Sendable conformances.
@@ -4468,16 +4505,6 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
44684505 -> NormalProtocolConformance * {
44694506 DeclContext *conformanceDC = nominal;
44704507 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-
44814508 // Conformance availability is currently tied to the declaring extension.
44824509 // FIXME: This is a hack--we should give conformances real availability.
44834510 auto inherits = ctx.AllocateCopy (makeArrayRef (
@@ -4490,7 +4517,7 @@ ProtocolConformance *GetImplicitSendableRequest::evaluate(
44904517 nominal->getModuleScopeContext (),
44914518 nullptr );
44924519 extension->setImplicit ();
4493- extension-> getAttrs (). add (attr );
4520+ addUnavailableAttrs (extension, nominal );
44944521
44954522 ctx.evaluator .cacheOutput (ExtendedTypeRequest{extension},
44964523 nominal->getDeclaredType ());
0 commit comments