Skip to content

Commit 1888724

Browse files
committed
Sema: Disallow protocols from refining less available protocols
Concrete types can conform to unavailable protocols because the witness table for the conformance is not required for use with the concrete type itself. However, protocols cannot have unavailable base protocols. I believe this was an oversight of the original implementation here.
1 parent dd62ccd commit 1888724

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Sema/TypeCheckAccess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
22322232
llvm::for_each(proto->getInherited(),
22332233
[&](TypeLoc requirement) {
22342234
checkType(requirement.getType(), requirement.getTypeRepr(), proto,
2235-
/*allowUnavailableProtocol=*/true);
2235+
/*allowUnavailableProtocol=*/false);
22362236
});
22372237

22382238
if (proto->getTrailingWhereClause()) {

test/Sema/availability_versions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ protocol ProtocolAvailableOn10_51 {
883883
}
884884

885885
@available(OSX, introduced: 10.9)
886-
protocol ProtocolAvailableOn10_9InheritingFromProtocolAvailableOn10_51 : ProtocolAvailableOn10_51 {
886+
protocol ProtocolAvailableOn10_9InheritingFromProtocolAvailableOn10_51 : ProtocolAvailableOn10_51 { // expected-error {{'ProtocolAvailableOn10_51' is only available in macOS 10.51 or newer}}
887887
}
888888

889889
@available(OSX, introduced: 10.51)

0 commit comments

Comments
 (0)