Sema: Check AnyObject requirements of variadic generic functions

This commit is contained in:
Slava Pestov
2022-10-21 00:14:28 -04:00
parent f3fcc44d17
commit c34f8d3a0b
2 changed files with 31 additions and 2 deletions

View File

@@ -3659,6 +3659,19 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
return getTypeMatchFailure(locator);
}
// ConformsTo constraints are generated when opening a generic
// signature with a RequirementKind::Conformance requirement, so
// we must handle pack types on the left by splitting up into
// smaller constraints.
if (auto *packType = type1->getAs<PackType>()) {
for (unsigned i = 0, e = packType->getNumElements(); i < e; ++i) {
addConstraint(kind, packType->getElementType(i), type2,
locator.withPathElement(LocatorPathElt::PackElement(i)));
}
return getTypeMatchSuccess();
}
TypeMatchOptions subflags = getDefaultDecompositionOptions(flags);
// Handle existential metatypes.
@@ -7522,7 +7535,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
return SolutionKind::Solved;
}
auto *loc = getConstraintLocator(locator);
/// Record the given conformance as the result, adding any conditional