Skip to content

Commit 643eb82

Browse files
authored
Merge pull request #64751 from tshortli/relax-back-deployed-unavailability-diagnostic-5.9
[5.9] Sema: Relax `@backDeployed` availability conflict diagnostics.
2 parents ac9d913 + 420b36f commit 643eb82

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4320,15 +4320,19 @@ void AttributeChecker::checkBackDeployedAttrs(
43204320
// Unavailable decls cannot be back deployed.
43214321
if (auto unavailableAttrPair = VD->getSemanticUnavailableAttr()) {
43224322
auto unavailableAttr = unavailableAttrPair.value().first;
4323-
DeclName name;
4324-
unsigned accessorKind;
4325-
std::tie(accessorKind, name) = getAccessorKindAndNameForDiagnostics(VD);
4326-
diagnose(AtLoc, diag::attr_has_no_effect_on_unavailable_decl, Attr,
4327-
accessorKind, name, prettyPlatformString(Platform));
4328-
diagnose(unavailableAttr->AtLoc, diag::availability_marked_unavailable,
4329-
accessorKind, name)
4330-
.highlight(unavailableAttr->getRange());
4331-
continue;
4323+
4324+
if (unavailableAttr->Platform == PlatformKind::none ||
4325+
unavailableAttr->Platform == Attr->Platform) {
4326+
DeclName name;
4327+
unsigned accessorKind;
4328+
std::tie(accessorKind, name) = getAccessorKindAndNameForDiagnostics(VD);
4329+
diagnose(AtLoc, diag::attr_has_no_effect_on_unavailable_decl, Attr,
4330+
accessorKind, name, prettyPlatformString(Platform));
4331+
diagnose(unavailableAttr->AtLoc, diag::availability_marked_unavailable,
4332+
accessorKind, name)
4333+
.highlight(unavailableAttr->getRange());
4334+
continue;
4335+
}
43324336
}
43334337

43344338
// Verify that the decl is available before the back deployment boundary.

test/attr/File

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-typecheck-verify-swift -parse-as-library
2+
// RUN: %target-typecheck-verify-swift -parse-as-library -application-extension
3+
4+
@available(macOS 11, *)
5+
@available(macOSApplicationExtension, unavailable)
6+
public struct UnavailableMacOSExtensionsStruct {
7+
@backDeployed(before: macOS 12)
8+
public func memberFunc() {}
9+
}

0 commit comments

Comments
 (0)