Files
swift-mirror/test/Concurrency/implied_sendable_conformance_swift6.swift
Slava Pestov 0696ec6d50 Sema: Ban implied 'Sendable' conformance when strict concurrency enabled
You can't do this anymore:

    struct G<T> {}
    protocol P: Sendable {}
    extension G: P where T: P {}

Fixes rdar://95695543.
2024-07-02 17:09:50 -04:00

28 lines
1.3 KiB
Swift

// RUN: %target-typecheck-verify-swift -swift-version 6
protocol P: Sendable {}
protocol Q: Sendable {}
struct One<T> { // expected-note {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
var t: T // expected-error {{stored property 't' of 'Sendable'-conforming generic struct 'One' has non-sendable type 'T'}}
}
extension One: P where T: P {}
// expected-error@-1 {{conditional conformance of type 'One<T>' to protocol 'P' does not imply conformance to inherited protocol 'Sendable'}}
// expected-note@-2 {{did you mean to explicitly state the conformance like 'extension One: Sendable where ...'}}
struct Both<T> { // expected-note {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
var t: T // expected-error {{stored property 't' of 'Sendable'-conforming generic struct 'Both' has non-sendable type 'T'}}
}
extension Both: P where T: P {}
// expected-error@-1 {{conditional conformance of type 'Both<T>' to protocol 'P' does not imply conformance to inherited protocol 'Sendable'}}
// expected-note@-2 {{did you mean to explicitly state the conformance like 'extension Both: Sendable where ...'}}
extension Both: Q where T: Q {}
func takesSendable<T: Sendable>(_: T) {}
takesSendable(One<Int>(t: 3))
takesSendable(Both<Int>(t: 3))