@@ -4547,11 +4547,12 @@ void AttributeChecker::checkBackDeployedAttrs(
45474547 // Unavailable decls cannot be back deployed.
45484548 if (auto unavailableAttrPair = VD->getSemanticUnavailableAttr ()) {
45494549 auto unavailableAttr = unavailableAttrPair.value ().first ;
4550+ if (!inheritsAvailabilityFromPlatform (unavailableAttr->Platform ,
4551+ Attr->Platform )) {
4552+ auto platformString = prettyPlatformString (Attr->Platform );
45504553
4551- if (unavailableAttr->Platform == PlatformKind::none ||
4552- unavailableAttr->Platform == Attr->Platform ) {
4553- diagnose (AtLoc, diag::attr_has_no_effect_on_unavailable_decl, Attr,
4554- VD, prettyPlatformString (Platform));
4554+ diagnose (AtLoc, diag::attr_has_no_effect_on_unavailable_decl, Attr, VD,
4555+ platformString);
45554556 diagnose (unavailableAttr->AtLoc , diag::availability_marked_unavailable,
45564557 VD)
45574558 .highlight (unavailableAttr->getRange ());
@@ -4563,14 +4564,17 @@ void AttributeChecker::checkBackDeployedAttrs(
45634564 // If it's not, the attribute doesn't make sense since the back deployment
45644565 // fallback could never be executed at runtime.
45654566 if (auto availableRangeAttrPair = VD->getSemanticAvailableRangeAttr ()) {
4567+ auto beforePlatformString = prettyPlatformString (Attr->Platform );
4568+ auto beforeVersion = Attr->Version ;
45664569 auto availableAttr = availableRangeAttrPair.value ().first ;
4567- if (Attr->Version <= availableAttr->Introduced .value ()) {
4570+ auto introVersion = availableAttr->Introduced .value ();
4571+ StringRef introPlatformString = availableAttr->prettyPlatformString ();
4572+
4573+ if (Attr->Version <= introVersion) {
45684574 diagnose (AtLoc, diag::attr_has_no_effect_decl_not_available_before,
4569- Attr, VD, prettyPlatformString (Platform),
4570- Attr->Version );
4575+ Attr, VD, beforePlatformString, beforeVersion);
45714576 diagnose (availableAttr->AtLoc , diag::availability_introduced_in_version,
4572- VD, prettyPlatformString (availableAttr->Platform ),
4573- *availableAttr->Introduced )
4577+ VD, introPlatformString, introVersion)
45744578 .highlight (availableAttr->getRange ());
45754579 continue ;
45764580 }
0 commit comments