mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sendable conformances for source compatibility. If conformance lookup always prefers the conformance from the defining module, libraries introducing unavailable Sendable conformances can break source in clients that declare retroactive Sendable conformances. Instead, still prefer the available conformance, and always diagnose the client conformance as redundant (as a warning). Then, when the retroactive conformance is removed, the errors will surface, so the programmer has to take explicit action to experience the source break.
25 lines
1.2 KiB
Swift
25 lines
1.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/SendableConformances.swiftmodule -module-name SendableConformances %S/Inputs/SendableConformances.swift
|
|
|
|
// RUN: %target-swift-frontend -typecheck %s -verify -swift-version 6 -I %t
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
import SendableConformances
|
|
|
|
typealias RequireSendable<T: Sendable> = T
|
|
|
|
extension NonSendableClass: @retroactive @unchecked Sendable {}
|
|
// expected-warning@-1 {{conformance of 'NonSendableClass' to protocol 'Sendable' was already stated in the type's module 'SendableConformances'}}
|
|
|
|
typealias CheckNonSendableClass = RequireSendable<NonSendableClass>
|
|
|
|
extension SendableStruct: @retroactive @unchecked Sendable {}
|
|
// expected-warning@-1 {{conformance of 'SendableStruct' to protocol 'Sendable' was already stated in the type's module 'SendableConformances'}}
|
|
|
|
@available(*, unavailable)
|
|
extension AnotherSendableStruct: @retroactive @unchecked Sendable {}
|
|
// expected-warning@-1 {{conformance of 'AnotherSendableStruct' to protocol 'Sendable' was already stated in the type's module 'SendableConformances'}}
|
|
|
|
typealias CheckAnotherSendableStruct = RequireSendable<AnotherSendableStruct>
|