Merge pull request #71571 from xedin/copyable-fixes-for-variadics

[AST] Handle pack element types in `LookupConformanceInModuleRequest`
This commit is contained in:
Pavel Yaskevich
2024-02-13 09:52:29 -08:00
committed by GitHub
2 changed files with 21 additions and 11 deletions

View File

@@ -8492,18 +8492,23 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
return SolutionKind::Solved;
}
// Copyable is checked structurally, so for better performance, split apart
// this constraint into individual Copyable constraints on each tuple element.
if (auto *tupleType = type->getAs<TupleType>()) {
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
for (unsigned i = 0, e = tupleType->getNumElements(); i < e; ++i) {
addConstraint(ConstraintKind::ConformsTo,
tupleType->getElementType(i),
protocol->getDeclaredInterfaceType(),
locator.withPathElement(LocatorPathElt::TupleElement(i)));
}
// FIXME: This is already handled by tuple conformance lookup path and
// should be removed once non-copyable generics are enabled by default.
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS) {
// Copyable is checked structurally, so for better performance, split apart
// this constraint into individual Copyable constraints on each tuple
// element.
if (auto *tupleType = type->getAs<TupleType>()) {
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
for (unsigned i = 0, e = tupleType->getNumElements(); i < e; ++i) {
addConstraint(
ConstraintKind::ConformsTo, tupleType->getElementType(i),
protocol->getDeclaredInterfaceType(),
locator.withPathElement(LocatorPathElt::TupleElement(i)));
}
return SolutionKind::Solved;
return SolutionKind::Solved;
}
}
}