Skip to content

Commit 81d211f

Browse files
authored
Merge pull request #42118 from DougGregor/objc-inherit-marker-protocol
An `@objc` protocol can inherit from a marker protocol
2 parents b6b64c9 + 8092a28 commit 81d211f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,11 @@ bool IsObjCRequest::evaluate(Evaluator &evaluator, ValueDecl *VD) const {
16141614
if (auto attr = proto->getAttrs().getAttribute<ObjCAttr>()) {
16151615
isObjC = objCReasonForObjCAttr(attr);
16161616

1617-
// If the protocol is @objc, it may only refine other @objc protocols.
1617+
// If the protocol is @objc, it may only refine other @objc protocols and
1618+
// marker protocols.
16181619
// FIXME: Revisit this restriction.
16191620
for (auto inherited : proto->getInheritedProtocols()) {
1620-
if (!inherited->isObjC()) {
1621+
if (!inherited->isObjC() && !inherited->isMarkerProtocol()) {
16211622
proto->diagnose(diag::objc_protocol_inherits_non_objc_protocol,
16221623
proto->getDeclaredInterfaceType(),
16231624
inherited->getDeclaredInterfaceType());
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -verify -parse-as-library
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: concurrency
5+
import Foundation
6+
7+
@objc protocol P: Sendable { }

0 commit comments

Comments
 (0)