Skip to content

Commit c71b7c5

Browse files
committed
[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.
1 parent b1f0bc4 commit c71b7c5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
17481748
// If type inference from default arguments is enabled, let's
17491749
// add a constraint from the parameter if necessary, otherwise
17501750
// there is nothing to do but move to the next parameter.
1751-
if (parameterBindings[paramIdx].empty()) {
1751+
if (parameterBindings[paramIdx].empty() && callee) {
17521752
auto &ctx = cs.getASTContext();
17531753

17541754
if (ctx.TypeCheckerOpts.EnableTypeInferenceFromDefaultArguments) {

test/decl/func/vararg.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
var t1a: (Int...) = (1)
45
// expected-error@-1 {{cannot create a variadic tuple}}

0 commit comments

Comments
 (0)