Open
Description
Description
By creating an extension on a protocol with a where Self: Sendable
constraint, you can use types as Sendable
in the extension.
When you then conform a non-sendable type to another protocol that is witnessed by the where Self: Sendable
extension mentioned above, things compile without errors.
Reproduction
protocol P {
func doIt()
}
protocol F: AnyObject {
var x: Int { get set }
}
class NonSendable: F {
var x = 0
}
extension NonSendable: P {} // is this a bug?
extension F where Self: Sendable {
func doIt() {
Task { print(self.x) }
x += 1
}
}
func test() {
let f: P = NonSendable()
f.doIt()
}
Expected behavior
This should not compile unless the extension with the protocol conformance has the same where Self: Sendable
constraint.
Environment
Apple Swift version 6.0.2 (swift-6.0.2-RELEASE)
Target: arm64-apple-macosx15.0
same behavior on
Apple Swift version 6.1-dev (LLVM 42f3e8ef873e24d, Swift c690fef)
Target: arm64-apple-macosx15.0
Additional information
No response