Skip to content

Commit f40db0c

Browse files
committed
all existentials are _Copyable
1 parent d8377bb commit f40db0c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/AST/Module.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,13 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
12061206
if (!protocol->existentialConformsToSelf())
12071207
return ProtocolConformanceRef::forInvalid();
12081208

1209+
// All existentials are Copyable.
1210+
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
1211+
return ProtocolConformanceRef(
1212+
ctx.getBuiltinConformance(type, protocol, GenericSignature(), {},
1213+
BuiltinConformanceKind::Synthesized));
1214+
}
1215+
12091216
auto layout = type->getExistentialLayout();
12101217

12111218
// Due to an IRGen limitation, witness tables cannot be passed from an

test/Constraints/moveonly_constraints.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ func checkStdlibTypes(_ mo: MO) {
164164
let s: String = "hello \(mo)" // expected-error {{move-only type 'MO' cannot be used with generics yet}}
165165
}
166166

167+
func copyableExistentials(_ a: Any, _ e1: Error, _ e2: any Error, _ ah: AnyHashable) {
168+
takeGeneric(a)
169+
takeGeneric(e1)
170+
takeGeneric(e2)
171+
takeGeneric(ah)
172+
}
173+
167174
// ensure that associated types can't be witnessed by move-only types
168175

169176
protocol HasType<Ty> {

0 commit comments

Comments
 (0)