Skip to content

Commit 9df17ff

Browse files
committed
Allow implied conditional conformances to marker protocols.
This improves source compatibility in cases where a marker protocol is introduced after-the-fact (e.g., for `Error`), and is safe because there's no runtime component to marker protocols.
1 parent 93a28da commit 9df17ff

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,8 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
19621962
}
19631963

19641964
bool impliedDisablesMissingWitnessFixits = false;
1965-
if (conformance->getSourceKind() == ConformanceEntryKind::Implied) {
1965+
if (conformance->getSourceKind() == ConformanceEntryKind::Implied &&
1966+
!Proto->isMarkerProtocol()) {
19661967
// We've got something like:
19671968
//
19681969
// protocol Foo : Proto {}

test/attr/attr_marker_protocol.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ func testNotOkay(a: Any) {
5151
func inner(p3: P3) { }
5252
}
5353

54+
55+
@_marker protocol P8 { }
56+
protocol P9: P8 { }
57+
58+
// Implied conditional conformance to P8 is okay because P8 is a marker
59+
// protocol.
60+
extension Array: P9 where Element: P9 { }

0 commit comments

Comments
 (0)