I don’t think the problem here is the negative copyable constraint ?: Copyable
, but rather implicit requirements. I think a better name for your attribute is @implicitConstraint(MyProtocol)
, which —as you say— could generalize to other feature like reflection.
This syntax generalizes a lot better. Swift already synthesizes some implicit conformances (e.g. Sendable), so a general syntax would be a great way to opt out. The syntax would also naturally extend to opting out of the aforementioned implicit constraints. But more importantly, Copyable
should be a protocol. IIRC, the compiler generates witnesses for copyable types that describe how they should be copied. Even if Copyable
’s requirement is an underscore-prefixed __copy()
method, implementing and explaining copies in Swift would be more straightforward. So it only makes sense that a move-only type would shed its implicit Copyable
conformance, like any other conformance (?: Sendable
), with a ?: Copyable
syntax.