Skip to content

Commit f02fe4e

Browse files
committed
[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. (cherry picked from commit 70e4cf0)
1 parent fc301f4 commit f02fe4e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6290,11 +6290,18 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
62906290
*choice, [this](Type type) -> Type { return simplifyType(type); }))
62916291
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
62926292

6293+
#ifndef NDEBUG
6294+
// If variadic generics are not involved, interface type should
6295+
// always match applied type.
62936296
if (auto *fn = fnInterfaceType->getAs<AnyFunctionType>()) {
6294-
assert(fn->getNumParams() == fnType->getNumParams() &&
6295-
"Parameter mismatch?");
6296-
(void)fn;
6297+
if (llvm::none_of(fn->getParams(), [&](const auto &param) {
6298+
return param.getPlainType()->hasParameterPack();
6299+
})) {
6300+
assert(fn->getNumParams() == fnType->getNumParams() &&
6301+
"Parameter mismatch?");
6302+
}
62976303
}
6304+
#endif
62986305
} else {
62996306
fnInterfaceType = resolveInterfaceType(rawFnType);
63006307
}

0 commit comments

Comments
 (0)