Skip to content

Commit 0fdb9a3

Browse files
committed
[ConstraintSystem] Bail out of inference from default arguments if there
is no parameter list for the callee. This can happen when the callee is a closure that has been assigned to a variable.
1 parent c71b7c5 commit 0fdb9a3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,10 +1753,12 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
17531753

17541754
if (ctx.TypeCheckerOpts.EnableTypeInferenceFromDefaultArguments) {
17551755
auto *paramList = getParameterList(callee);
1756-
auto *PD = paramList->get(paramIdx);
1756+
if (!paramList)
1757+
continue;
17571758

17581759
// There is nothing to infer if parameter doesn't have any
17591760
// generic parameters in its type.
1761+
auto *PD = paramList->get(paramIdx);
17601762
if (!PD->getInterfaceType()->hasTypeParameter())
17611763
continue;
17621764

test/expr/closure/basic.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
2+
// RUN: %target-typecheck-verify-swift -enable-experimental-type-inference-from-defaults
23

34
func takeIntToInt(_ f: (Int) -> Int) { }
45
func takeIntIntToInt(_ f: (Int, Int) -> Int) { }

0 commit comments

Comments
 (0)