@@ -3035,7 +3035,7 @@ class UnavailabilityDiagnosticInfo {
3035
3035
: DiagnosticStatus(status), Attr(attr) {};
3036
3036
3037
3037
Status getStatus () const { return DiagnosticStatus; }
3038
- const AvailableAttr * getAttr () const { return Attr. getParsedAttr () ; }
3038
+ SemanticAvailableAttr getAttr () const { return Attr; }
3039
3039
AvailabilityDomain getDomain () const { return Attr.getDomain (); }
3040
3040
StringRef getDomainName () const {
3041
3041
return getDomain ().getNameForDiagnostics ();
@@ -3116,14 +3116,14 @@ bool diagnoseExplicitUnavailability(
3116
3116
diagnosticInfo->shouldHideDomainNameInUnversionedDiagnostics ()
3117
3117
? " "
3118
3118
: versionedPlatform;
3119
- const AvailableAttr * attr = diagnosticInfo->getAttr ();
3119
+ auto attr = diagnosticInfo->getAttr ();
3120
3120
3121
3121
// Downgrade unavailable Sendable conformance diagnostics where
3122
3122
// appropriate.
3123
3123
auto behavior =
3124
3124
behaviorLimitForExplicitUnavailability (rootConf, where.getDeclContext ());
3125
3125
3126
- EncodedDiagnosticMessage EncodedMessage (attr-> Message );
3126
+ EncodedDiagnosticMessage EncodedMessage (attr. getMessage () );
3127
3127
diags
3128
3128
.diagnose (loc, diag::conformance_availability_unavailable, type, proto,
3129
3129
platform.empty (), platform, EncodedMessage.Message )
@@ -3135,17 +3135,17 @@ bool diagnoseExplicitUnavailability(
3135
3135
diags
3136
3136
.diagnose (ext, diag::conformance_availability_marked_unavailable, type,
3137
3137
proto)
3138
- .highlight (attr->getRange ());
3138
+ .highlight (attr. getParsedAttr () ->getRange ());
3139
3139
break ;
3140
3140
case UnavailabilityDiagnosticInfo::Status::IntroducedInVersion:
3141
3141
diags.diagnose (ext, diag::conformance_availability_introduced_in_version,
3142
- type, proto, versionedPlatform, *attr-> Introduced );
3142
+ type, proto, versionedPlatform, *attr. getIntroduced () );
3143
3143
break ;
3144
3144
case UnavailabilityDiagnosticInfo::Status::Obsoleted:
3145
3145
diags
3146
3146
.diagnose (ext, diag::conformance_availability_obsoleted, type, proto,
3147
- versionedPlatform, *attr-> Obsoleted )
3148
- .highlight (attr->getRange ());
3147
+ versionedPlatform, *attr. getObsoleted () )
3148
+ .highlight (attr. getParsedAttr () ->getRange ());
3149
3149
break ;
3150
3150
}
3151
3151
return true ;
@@ -3532,9 +3532,8 @@ bool diagnoseExplicitUnavailability(
3532
3532
if (!diagnosticInfo)
3533
3533
return false ;
3534
3534
3535
- auto *Attr = diagnosticInfo->getAttr ();
3536
- if (Attr->getPlatformAgnosticAvailability () ==
3537
- PlatformAgnosticAvailabilityKind::UnavailableInSwift) {
3535
+ auto Attr = diagnosticInfo->getAttr ();
3536
+ if (Attr.getDomain ().isSwiftLanguage () && !Attr.isVersionSpecific ()) {
3538
3537
if (shouldAllowReferenceToUnavailableInSwiftDeclaration (D, Where))
3539
3538
return false ;
3540
3539
}
@@ -3558,20 +3557,21 @@ bool diagnoseExplicitUnavailability(
3558
3557
? DiagnosticBehavior::Warning
3559
3558
: DiagnosticBehavior::Unspecified;
3560
3559
3561
- if (!Attr->Rename .empty ()) {
3560
+ auto message = Attr.getMessage ();
3561
+ auto rename = Attr.getRename ();
3562
+ if (!rename.empty ()) {
3562
3563
SmallString<32 > newNameBuf;
3563
3564
std::optional<ReplacementDeclKind> replaceKind =
3564
- describeRename (ctx, Attr-> Rename , D, newNameBuf);
3565
+ describeRename (ctx, Attr. getRename () , D, newNameBuf);
3565
3566
unsigned rawReplaceKind = static_cast <unsigned >(
3566
3567
replaceKind.value_or (ReplacementDeclKind::None));
3567
- StringRef newName = replaceKind ? newNameBuf.str () : Attr->Rename ;
3568
- EncodedDiagnosticMessage EncodedMessage (Attr->Message );
3569
- auto diag =
3570
- diags.diagnose (Loc, diag::availability_decl_unavailable_rename,
3571
- D, replaceKind.has_value (),
3572
- rawReplaceKind, newName, EncodedMessage.Message );
3573
- diag.limitBehavior (limit);
3574
- attachRenameFixIts (diag);
3568
+ StringRef newName = replaceKind ? newNameBuf.str () : rename;
3569
+ EncodedDiagnosticMessage EncodedMessage (message);
3570
+ auto diag = diags.diagnose (Loc, diag::availability_decl_unavailable_rename,
3571
+ D, replaceKind.has_value (), rawReplaceKind,
3572
+ newName, EncodedMessage.Message );
3573
+ diag.limitBehavior (limit);
3574
+ attachRenameFixIts (diag);
3575
3575
} else if (isSubscriptReturningString (D, ctx)) {
3576
3576
diags.diagnose (Loc, diag::availability_string_subscript_migration)
3577
3577
.highlight (R)
@@ -3582,31 +3582,33 @@ bool diagnoseExplicitUnavailability(
3582
3582
return true ;
3583
3583
} else {
3584
3584
auto unavailableDiagnosticPlatform = platform;
3585
- AvailabilityInference::updatePlatformStringForFallback (Attr, ctx, unavailableDiagnosticPlatform);
3586
- EncodedDiagnosticMessage EncodedMessage (Attr->Message );
3585
+ AvailabilityInference::updatePlatformStringForFallback (
3586
+ Attr.getParsedAttr (), ctx, unavailableDiagnosticPlatform);
3587
+ EncodedDiagnosticMessage EncodedMessage (message);
3587
3588
diags
3588
3589
.diagnose (Loc, diag::availability_decl_unavailable, D, platform.empty (),
3589
3590
unavailableDiagnosticPlatform, EncodedMessage.Message )
3590
3591
.highlight (R)
3591
3592
.limitBehavior (limit);
3592
3593
}
3593
3594
3595
+ auto sourceRange = Attr.getParsedAttr ()->getRange ();
3594
3596
switch (diagnosticInfo->getStatus ()) {
3595
3597
case UnavailabilityDiagnosticInfo::Status::AlwaysUnavailable:
3596
3598
diags.diagnose (D, diag::availability_marked_unavailable, D)
3597
- .highlight (Attr-> getRange () );
3599
+ .highlight (sourceRange );
3598
3600
break ;
3599
3601
case UnavailabilityDiagnosticInfo::Status::IntroducedInVersion:
3600
3602
diags
3601
3603
.diagnose (D, diag::availability_introduced_in_version, D,
3602
- versionedPlatform, *Attr-> Introduced )
3603
- .highlight (Attr-> getRange () );
3604
+ versionedPlatform, *Attr. getIntroduced () )
3605
+ .highlight (sourceRange );
3604
3606
break ;
3605
3607
case UnavailabilityDiagnosticInfo::Status::Obsoleted:
3606
3608
diags
3607
3609
.diagnose (D, diag::availability_obsoleted, D, versionedPlatform,
3608
- *Attr-> Obsoleted )
3609
- .highlight (Attr-> getRange () );
3610
+ *Attr. getObsoleted () )
3611
+ .highlight (sourceRange );
3610
3612
break ;
3611
3613
}
3612
3614
return true ;
0 commit comments