mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The _Copyable constraint was implemented as a marker protocol. That protocol is part of the KnownProtocol's in the compiler. When `ASTContext::getProtocol(KnownProtocolKind kind)` tries to find the ProtocolDecl for Copyable, it will look in the stdlib module (i.e., Swift module), which is where I initially planned to put it. That created problems initially when some regression tests use `-parse-stdlib` failed to do that protocol lookup, which is essential for adding the constraint (given the current implementation). That led to believe we need to pull Copyable out of the stdlib, but that's wrong. In fact, when building the Swift module itself, we do `-parse-stdlib` but we also include `-module-name Swift`. This causes the _Copyable protocol defined in the Stdlib to be correctly discovered while building the stdlib itself (see the test case in this commit). So, the only downside of having the Copyable protocol in the Stdlib is that `-parse-stdlib` tests in the compiler can't use move-only types correctly, as they'll be allowed in generic contexts. No real program would build like this. Until I have time to do a further refactoring, this is an acceptable trade-off. fixes rdar://104898230
1.8 KiB
1.8 KiB