This came up in the review of SE-0302, because Sendable
is inferred structurally for non-public struct and enum types, and there is currently no way to disable the inference. I'm inclined toward using (un)availability on the conformance to spell "this is intentionally not Sendable
", rather than invent something new, e.g.,
public struct MyType : @available(unavailable, *) Sendable {
var x, y: Double
// some day we may add some shared state here
}
To your use case, if a module explicitly declares an unavailable Sendable
conformance, importing modules should complain if they need MyType
to be Sendable
.
If every type is explicitly marked as Sendable
or having unavailable Sendable
conformance, then there's no observable difference in importing modules as to whether the module has adopted concurrency or not.
Oh, that's not what I meant. I don't want to ban this:
import A
// Point3D is from module A
extension Point3D: @unchecked Sendable { }
I want to turn it into an error if A
adopts concurrency and doesn't make Point3D
Sendable
:
// module A adopts concurrency
public struct Point3D { ... } // not Sendable
Doug