@@ -7076,20 +7076,25 @@ void AttributeChecker::visitMarkerAttr(MarkerAttr *attr) {
7076
7076
if (!proto)
7077
7077
return ;
7078
7078
7079
- // A marker protocol cannot inherit a non-marker protocol.
7080
- for (auto inheritedProto : proto->getInheritedProtocols ()) {
7081
- if (!inheritedProto->isMarkerProtocol ()) {
7082
- proto->diagnose (
7083
- diag::marker_protocol_inherit_nonmarker,
7084
- proto->getName (), inheritedProto->getName ());
7085
- inheritedProto->diagnose ( diag::decl_declared_here, inheritedProto);
7086
- }
7087
- }
7079
+ for (auto req : proto->getRequirementSignature ().getRequirements ()) {
7080
+ if (!req.getFirstType ()->isEqual (proto->getSelfInterfaceType ()))
7081
+ continue ;
7088
7082
7089
- if (Type superclass = proto->getSuperclass ()) {
7090
- proto->diagnose (
7083
+ if (req.getKind () == RequirementKind::Superclass) {
7084
+ // A marker protocol cannot have a superclass requirement.
7085
+ proto->diagnose (
7091
7086
diag::marker_protocol_inherit_class,
7092
- proto->getName (), superclass);
7087
+ proto->getName (), req.getSecondType ());
7088
+ } else if (req.getKind () == RequirementKind::Conformance) {
7089
+ // A marker protocol cannot inherit a non-marker protocol.
7090
+ auto inheritedProto = req.getProtocolDecl ();
7091
+ if (!inheritedProto->isMarkerProtocol ()) {
7092
+ proto->diagnose (
7093
+ diag::marker_protocol_inherit_nonmarker,
7094
+ proto->getName (), inheritedProto->getName ());
7095
+ inheritedProto->diagnose ( diag::decl_declared_here, inheritedProto);
7096
+ }
7097
+ }
7093
7098
}
7094
7099
7095
7100
// A marker protocol cannot have any requirements.
0 commit comments