mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
all existentials are _Copyable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user