@@ -4547,11 +4547,12 @@ void AttributeChecker::checkBackDeployedAttrs(
4547
4547
// Unavailable decls cannot be back deployed.
4548
4548
if (auto unavailableAttrPair = VD->getSemanticUnavailableAttr ()) {
4549
4549
auto unavailableAttr = unavailableAttrPair.value ().first ;
4550
+ if (!inheritsAvailabilityFromPlatform (unavailableAttr->Platform ,
4551
+ Attr->Platform )) {
4552
+ auto platformString = prettyPlatformString (Attr->Platform );
4550
4553
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);
4555
4556
diagnose (unavailableAttr->AtLoc , diag::availability_marked_unavailable,
4556
4557
VD)
4557
4558
.highlight (unavailableAttr->getRange ());
@@ -4563,14 +4564,17 @@ void AttributeChecker::checkBackDeployedAttrs(
4563
4564
// If it's not, the attribute doesn't make sense since the back deployment
4564
4565
// fallback could never be executed at runtime.
4565
4566
if (auto availableRangeAttrPair = VD->getSemanticAvailableRangeAttr ()) {
4567
+ auto beforePlatformString = prettyPlatformString (Attr->Platform );
4568
+ auto beforeVersion = Attr->Version ;
4566
4569
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) {
4568
4574
diagnose (AtLoc, diag::attr_has_no_effect_decl_not_available_before,
4569
- Attr, VD, prettyPlatformString (Platform),
4570
- Attr->Version );
4575
+ Attr, VD, beforePlatformString, beforeVersion);
4571
4576
diagnose (availableAttr->AtLoc , diag::availability_introduced_in_version,
4572
- VD, prettyPlatformString (availableAttr->Platform ),
4573
- *availableAttr->Introduced )
4577
+ VD, introPlatformString, introVersion)
4574
4578
.highlight (availableAttr->getRange ());
4575
4579
continue ;
4576
4580
}
0 commit comments