Skip to content

Commit 396e8f0

Browse files
authored
Merge pull request swiftlang#79849 from tshortli/allow-unavailable-proto-requirements-in-swiftinterface
Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces
2 parents fda7f53 + 6284dd4 commit 396e8f0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5106,7 +5106,10 @@ void AttributeChecker::checkAvailableAttrs(ArrayRef<AvailableAttr *> attrs) {
51065106
if (VD->isProtocolRequirement() && !PD->isObjC()) {
51075107
diagnoseAndRemoveAttr(
51085108
const_cast<AvailableAttr *>(attr.getParsedAttr()),
5109-
diag::unavailable_method_non_objc_protocol);
5109+
diag::unavailable_method_non_objc_protocol)
5110+
.warnInSwiftInterface(D->getDeclContext());
5111+
// Be lenient in interfaces to accomodate @_spi_available, which has
5112+
// been accepted historically.
51105113
return;
51115114
}
51125115
}

test/ModuleInterface/availability-storage-macos.swift renamed to test/ModuleInterface/availability-macos.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,16 @@ public enum EnumWithAssociatedValues {
6464
@available(macOS 51, *)
6565
case introducedAtDeploymentWithAssoc(Int)
6666
}
67+
68+
// CHECK-LABEL: public protocol Proto
69+
public protocol Proto {
70+
// CHECK: @available(macOS 99, *)
71+
// CHECK-NEXT: func reqIntroducedAfterDeployment()
72+
@available(macOS 99, *)
73+
func reqIntroducedAfterDeployment()
74+
75+
// CHECK: @available(macOS, unavailable)
76+
// CHECK-NEXT: func reqIntroducedAsSPIAfterDeployment()
77+
@_spi_available(macOS 99, *)
78+
func reqIntroducedAsSPIAfterDeployment()
79+
}

0 commit comments

Comments
 (0)