@@ -7042,20 +7042,25 @@ void AttributeChecker::visitMarkerAttr(MarkerAttr *attr) {
7042
7042
if (!proto)
7043
7043
return ;
7044
7044
7045
- // A marker protocol cannot inherit a non-marker protocol.
7046
- for (auto inheritedProto : proto->getInheritedProtocols ()) {
7047
- if (!inheritedProto->isMarkerProtocol ()) {
7048
- proto->diagnose (
7049
- diag::marker_protocol_inherit_nonmarker,
7050
- proto->getName (), inheritedProto->getName ());
7051
- inheritedProto->diagnose ( diag::decl_declared_here, inheritedProto);
7052
- }
7053
- }
7045
+ for (auto req : proto->getRequirementSignature ().getRequirements ()) {
7046
+ if (!req.getFirstType ()->isEqual (proto->getSelfInterfaceType ()))
7047
+ continue ;
7054
7048
7055
- if (Type superclass = proto->getSuperclass ()) {
7056
- proto->diagnose (
7049
+ if (req.getKind () == RequirementKind::Superclass) {
7050
+ // A marker protocol cannot have a superclass requirement.
7051
+ proto->diagnose (
7057
7052
diag::marker_protocol_inherit_class,
7058
- proto->getName (), superclass);
7053
+ proto->getName (), req.getSecondType ());
7054
+ } else if (req.getKind () == RequirementKind::Conformance) {
7055
+ // A marker protocol cannot inherit a non-marker protocol.
7056
+ auto inheritedProto = req.getProtocolDecl ();
7057
+ if (!inheritedProto->isMarkerProtocol ()) {
7058
+ proto->diagnose (
7059
+ diag::marker_protocol_inherit_nonmarker,
7060
+ proto->getName (), inheritedProto->getName ());
7061
+ inheritedProto->diagnose ( diag::decl_declared_here, inheritedProto);
7062
+ }
7063
+ }
7059
7064
}
7060
7065
7061
7066
// A marker protocol cannot have any requirements.
0 commit comments