Skip to content

Commit 70e4cf0

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.
1 parent 8f4ad8b commit 70e4cf0

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
@@ -6278,11 +6278,18 @@ Solution::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
62786278
*choice, [this](Type type) -> Type { return simplifyType(type); }))
62796279
fnInterfaceType = fnInterfaceType->castTo<AnyFunctionType>()->getResult();
62806280

6281+
#ifndef NDEBUG
6282+
// If variadic generics are not involved, interface type should
6283+
// always match applied type.
62816284
if (auto *fn = fnInterfaceType->getAs<AnyFunctionType>()) {
6282-
assert(fn->getNumParams() == fnType->getNumParams() &&
6283-
"Parameter mismatch?");
6284-
(void)fn;
6285+
if (llvm::none_of(fn->getParams(), [&](const auto &param) {
6286+
return param.getPlainType()->hasParameterPack();
6287+
})) {
6288+
assert(fn->getNumParams() == fnType->getNumParams() &&
6289+
"Parameter mismatch?");
6290+
}
62856291
}
6292+
#endif
62866293
} else {
62876294
fnInterfaceType = resolveInterfaceType(rawFnType);
62886295
}

0 commit comments

Comments
 (0)