File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -8166,6 +8166,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
81668166 return SolutionKind::Solved;
81678167 }
81688168
8169+ // Copyable is checked structurally, so for better performance, split apart
8170+ // this constraint into individual Copyable constraints on each tuple element.
8171+ if (auto *tupleType = type->getAs<TupleType>()) {
8172+ if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
8173+ for (unsigned i = 0, e = tupleType->getNumElements(); i < e; ++i) {
8174+ addConstraint(ConstraintKind::ConformsTo,
8175+ tupleType->getElementType(i),
8176+ protocol->getDeclaredInterfaceType(),
8177+ locator.withPathElement(LocatorPathElt::TupleElement(i)));
8178+ }
8179+
8180+ return SolutionKind::Solved;
8181+ }
8182+ }
8183+
81698184 auto *loc = getConstraintLocator(locator);
81708185
81718186 /// Record the given conformance as the result, adding any conditional
Original file line number Diff line number Diff line change @@ -88,8 +88,8 @@ func testBasic(_ mo: borrowing MO) {
8888 genericVarArg ( 5 )
8989 genericVarArg ( mo) // expected-error {{move-only type 'MO' cannot be used with generics yet}}
9090
91- takeGeneric ( ( mo, 5 ) ) // expected-error {{global function 'takeGeneric' requires that 'MO' conform to '_Copyable' }}
92- takeGenericSendable ( ( mo, mo) ) // expected-error 2{{global function 'takeGenericSendable' requires that 'MO' conform to '_Copyable' }}
91+ takeGeneric ( ( mo, 5 ) ) // expected-error {{move-only type 'MO' cannot be used with generics yet }}
92+ takeGenericSendable ( ( mo, mo) ) // expected-error 2{{move-only type 'MO' cannot be used with generics yet }}
9393
9494 let singleton : ( MO ) = ( mo)
9595 takeGeneric ( singleton) // expected-error {{move-only type 'MO' cannot be used with generics yet}}
You can’t perform that action at this time.
0 commit comments