Files
swift-mirror/test/Concurrency/redundant_sendable_conformance.swift
Holly Borla b1397703a5 [ConformanceLookup] Just kidding, the compiler needs to prefer available
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.
2024-07-11 23:03:33 -07:00

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>