Swift 6.1 regression in Sendable checking

There is a regression in Sendable checking in Swift 6.1 which is now available in Xcode 16.3 beta. For example, when trying to build GRDB we now get the following compilation error:

Associated value 'formatted' of 'Sendable'-conforming enum 'DatabaseDateEncodingStrategy' has non-sendable type 'DateFormatter'

although the DateFormatter is indeed marked as Sendable in Foundation. I'm guessing this will cause issues in other projects as well if it's not fixed before the stable release.

There as an issue already opened in the repo: Swift 6.1 regression in Sendable checking · Issue #78635 · swiftlang/swift · GitHub

Could someone take a look and possibly fix it before the stable release?

2 Likes

Holly responded in that thread:

The problem is that DateFormatter is marked Sendable, but Formatter explicitly has an unavailable conformance to Sendable. It's not valid for a subclass to have an available conformance while a superclass does not -- types can only have one conformance to a protocol, and superclass conformances are inherited by subclasses. This is ultimately an issue with the Sendable annotations in Foundation, which @jmschonfeld is aware of.

This was exposed by #75135, which fixed an issue where people were getting bogus diagnostics because different parts of the compiler saw different conformances between the unavailable conformance and the available conformance.

Thanks. I had commented under this issue and she replied.