all existentials are _Copyable

This commit is contained in:
Kavon Farvardin
2023-01-26 18:42:22 -08:00
parent ae639adcf3
commit 9608351b3f
2 changed files with 14 additions and 0 deletions

View File

@@ -1206,6 +1206,13 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
if (!protocol->existentialConformsToSelf())
return ProtocolConformanceRef::forInvalid();
// All existentials are Copyable.
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
return ProtocolConformanceRef(
ctx.getBuiltinConformance(type, protocol, GenericSignature(), {},
BuiltinConformanceKind::Synthesized));
}
auto layout = type->getExistentialLayout();
// Due to an IRGen limitation, witness tables cannot be passed from an

View File

@@ -164,6 +164,13 @@ func checkStdlibTypes(_ mo: MO) {
let s: String = "hello \(mo)" // expected-error {{move-only type 'MO' cannot be used with generics yet}}
}
func copyableExistentials(_ a: Any, _ e1: Error, _ e2: any Error, _ ah: AnyHashable) {
takeGeneric(a)
takeGeneric(e1)
takeGeneric(e2)
takeGeneric(ah)
}
// ensure that associated types can't be witnessed by move-only types
protocol HasType<Ty> {