Why the error message says "non-marker protocol 'Dev'" when its a Marker protocol?
protocol Dev {}
class Emp<T> {}
extension Emp: Dev where T: Sendable {}
Arent both Dev and Sendable a Marker protocol? [check screenshot]
1 Like
xwu
(Xiaodi Wu)
2
A marker protocol is (for now) a compiler-internal feature using the underscored attribute @_marker. For practical purposes, the diagnostics is really saying for end users that you can only conditionally conform a protocol to Sendable based on a Sendable constraint.
3 Likes
JackYoustra
(Jack Youstra)
3
Just curious, why is this the case? Additionally, if I have
struct S<T> {
var t: T
}
protocol P {
associatedtype Value: Sendable & Equatable
}
extension S: P where T: Sendable & Equatable { }
This error will prevent compilation. What's the way around it?
Jumhyn
(Frederick Kellison-Linn)
4
One of the features of marker protocols is that they exist only at compile time and not at runtime. But non-marker protocol conformances can be discovered/inspected at runtime via, e.g., as?. If the conformance of a non-marker protocol depended on conformance to a marker protocol there would be no way to resolve such runtime queries.
4 Likes