[ConstraintSystem] Limit assert in getFunctionArgApplyInfo to types without type parameter packs

If function type of some declaration has a at least on type parameter
pack it could mean that number of parameters in "applied" type could
be different from that of "interface" type.
This commit is contained in:
Pavel Yaskevich
2023-05-22 11:32:36 -07:00
parent 8f4ad8b11a
commit 70e4cf0ac8

View File

@@ -6278,11 +6278,18 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
*choice, [this](Type type) -> Type { return simplifyType(type); }))
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
#ifndef NDEBUG
// If variadic generics are not involved, interface type should
// always match applied type.
if (auto *fn = fnInterfaceType->getAs<AnyFunctionType>()) {
assert(fn->getNumParams() == fnType->getNumParams() &&
"Parameter mismatch?");
(void)fn;
if (llvm::none_of(fn->getParams(), [&](const auto &param) {
return param.getPlainType()->hasParameterPack();
})) {
assert(fn->getNumParams() == fnType->getNumParams() &&
"Parameter mismatch?");
}
}
#endif
} else {
fnInterfaceType = resolveInterfaceType(rawFnType);
}