Skip to content

Commit 25aa49b

Browse files
committed
[NCGenerics] Sendable doesn't require Copyable
1 parent c7c9d80 commit 25aa49b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stdlib/public/core/Sendable.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@
129129
/// ### Sendable Metatypes
130130
///
131131
/// Metatypes such as `Int.Type` implicitly conform to the `Sendable` protocol.
132+
#if $NoncopyableGenerics && $NonescapableTypes
133+
@_marker public protocol Sendable: ~Copyable, ~Escapable { }
134+
#elseif $NoncopyableGenerics
135+
@_marker public protocol Sendable: ~Copyable { }
136+
#else
132137
@_marker public protocol Sendable { }
138+
#endif
133139
///
134140
/// A type whose values can safely be passed across concurrency domains by copying,
135141
/// but which disables some safety checking at the conformance site.

test/Generics/inverse_generics.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ protocol Test: ~Copyable {
101101
init?() // expected-error {{noncopyable types cannot have failable initializers yet}}
102102
}
103103

104+
struct NoncopyableAndSendable: ~Copyable, Sendable {}
105+
104106
/// ---------------
105107

106108
// expected-note@+2 {{consider adding '~Copyable' to generic enum 'Maybe'}}

0 commit comments

Comments
 (0)