Skip to content

Commit 1e0c6c2

Browse files
committed
[Sema] fix tuples and NoncopyableGenerics
The generic signature for the built-in TupleDecl was incorrect, stating that the Element type must be Copyable. That in combination with an extension that says tuples are Copyable when Element is copyable was giving unconditional Copyable conformances for tuples that never actually get checked. Given that the existence of a conformance and no out-standing conditional requirements is now what is used to determine if a value is noncopyable, this was causing tuples with noncopyable elements to report that they are copyable in `isNoncopyable` requests.
1 parent f76360c commit 1e0c6c2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6174,6 +6174,17 @@ BuiltinTupleDecl *ASTContext::getBuiltinTupleDecl() {
61746174
result = new (*this) BuiltinTupleDecl(Id_TheTupleType, dc);
61756175
result->setAccess(AccessLevel::Public);
61766176

6177+
// Avoid going through InferredGenericSignatureRequest and directly set the
6178+
// generic signature to <each Element>
6179+
{
6180+
GenericParamList *list = result->getGenericParams();
6181+
assert(list->size() == 1);
6182+
auto paramTy = (*list->begin())->getDeclaredInterfaceType()
6183+
->castTo<GenericTypeParamType>();
6184+
auto baseSig = GenericSignature::get({paramTy}, {});
6185+
result->setGenericSignature(baseSig);
6186+
}
6187+
61776188
// Cook up conditional conformances to Sendable and Copyable.
61786189
auto buildFakeExtension = [&](ProtocolDecl *proto) {
61796190
auto protoTy = proto->getDeclaredInterfaceType();

0 commit comments

Comments
 (0)