Files
swift-mirror/test/Concurrency/implied_sendable_conformance_swift5.swift
Slava Pestov 252abb5365 Sema: Key the implied Sendable conformance behavior off of -swift-version instead of -strict-concurrency
Also add some comments to explain what in the world is going on
with the new checks.
2024-07-06 12:05:45 -04:00

24 lines
998 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5 -strict-concurrency=complete
// RUN: %target-swift-emit-silgen %s -swift-version 5 -strict-concurrency=complete
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-warning {{stored property 't' of 'Sendable'-conforming generic struct 'One' has non-sendable type 'T'; this is an error in the Swift 6 language mode}}
}
extension One: P where T: P {}
struct Both<T> { // expected-note {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
var t: T // expected-warning {{stored property 't' of 'Sendable'-conforming generic struct 'Both' has non-sendable type 'T'; this is an error in the Swift 6 language mode}}
}
extension Both: P where T: P {}
extension Both: Q where T: Q {}
func takesSendable<T: Sendable>(_: T) {}
takesSendable(One<Int>(t: 3))
takesSendable(Both<Int>(t: 3))