Supressing retroactive conformance warning while supporting both Swift 5.10 and 6.0

i suspect the answer to this is no, but i’m asking just to be sure.

i have a lot of cross-package conformances in a number of code bases that are doing some #if #else heroics to maintain compatibility with both versions of Swift:

#if swift(>=6.0)
extension Seconds:@retroactive AtomicValue
{
}
#else
extension Seconds:AtomicValue
{
}
#endif

are there less unwieldy ways to define these conformances?

According to SE-0364:

@retroactive is a new attribute, but it is purely additive; it can be accepted by all language versions. It does mean projects building with an older Swift will not have access to this syntax, so as a source compatible fallback, a client can silence this warning by fully-qualifying all types in the extension. As an example, the above conformance can also be written as

extension Foundation.Date: Swift.Identifiable {
    // ...
}
4 Likes

that’s perfect, thanks!

1 Like