Skip to content

Commit bb26b66

Browse files
committed
[CSSimplify] Don't attempt to destructure tuples to check for Copyable when non-copyable generics feature is enabled
1 parent 0e75312 commit bb26b66

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8492,18 +8492,23 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
84928492
return SolutionKind::Solved;
84938493
}
84948494

8495-
// Copyable is checked structurally, so for better performance, split apart
8496-
// this constraint into individual Copyable constraints on each tuple element.
8497-
if (auto *tupleType = type->getAs<TupleType>()) {
8498-
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
8499-
for (unsigned i = 0, e = tupleType->getNumElements(); i < e; ++i) {
8500-
addConstraint(ConstraintKind::ConformsTo,
8501-
tupleType->getElementType(i),
8502-
protocol->getDeclaredInterfaceType(),
8503-
locator.withPathElement(LocatorPathElt::TupleElement(i)));
8504-
}
8495+
// FIXME: This is already handled by tuple conformance lookup path and
8496+
// should be removed once non-copyable generics are enabled by default.
8497+
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS) {
8498+
// Copyable is checked structurally, so for better performance, split apart
8499+
// this constraint into individual Copyable constraints on each tuple
8500+
// element.
8501+
if (auto *tupleType = type->getAs<TupleType>()) {
8502+
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
8503+
for (unsigned i = 0, e = tupleType->getNumElements(); i < e; ++i) {
8504+
addConstraint(
8505+
ConstraintKind::ConformsTo, tupleType->getElementType(i),
8506+
protocol->getDeclaredInterfaceType(),
8507+
locator.withPathElement(LocatorPathElt::TupleElement(i)));
8508+
}
85058509

8506-
return SolutionKind::Solved;
8510+
return SolutionKind::Solved;
8511+
}
85078512
}
85088513
}
85098514

0 commit comments

Comments
 (0)