mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #71571 from xedin/copyable-fixes-for-variadics
[AST] Handle pack element types in `LookupConformanceInModuleRequest`
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user