File tree 2 files changed +17
-2
lines changed 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(
8166
8166
return SolutionKind::Solved;
8167
8167
}
8168
8168
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
+
8169
8184
auto *loc = getConstraintLocator(locator);
8170
8185
8171
8186
/// 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) {
88
88
genericVarArg ( 5 )
89
89
genericVarArg ( mo) // expected-error {{move-only type 'MO' cannot be used with generics yet}}
90
90
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 }}
93
93
94
94
let singleton : ( MO ) = ( mo)
95
95
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