[ConstraintSystem] Only attempt to infer a type from a default argument

if there is a non-null callee.

Otherwise, getParameterList(callee) will crash if the callee is a closure.
Closures can't have default arguments anyway, so there's no need to
attempt this new inference.
This commit is contained in:
Holly Borla
2022-03-24 23:26:24 -07:00
parent b1f0bc44ea
commit c71b7c500e
2 changed files with 2 additions and 1 deletions

View File

@@ -1748,7 +1748,7 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
// If type inference from default arguments is enabled, let's
// add a constraint from the parameter if necessary, otherwise
// there is nothing to do but move to the next parameter.
if (parameterBindings[paramIdx].empty()) {
if (parameterBindings[paramIdx].empty() && callee) {
auto &ctx = cs.getASTContext();
if (ctx.TypeCheckerOpts.EnableTypeInferenceFromDefaultArguments) {