File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -208,15 +208,29 @@ static void determineBestChoicesInContext(
208
208
if (!isViableOverload (decl))
209
209
return ;
210
210
211
- if (overloadType->getNumParams () != argFuncType->getNumParams ())
212
- return ;
211
+ ParameterListInfo paramListInfo (
212
+ overloadType->getParams (), decl,
213
+ hasAppliedSelf (cs, choice->getOverloadChoice ()));
213
214
214
215
double score = 0.0 ;
215
216
for (unsigned i = 0 , n = overloadType->getNumParams (); i != n; ++i) {
217
+ const auto ¶m = overloadType->getParams ()[i];
218
+
219
+ if (i >= candidateArgumentTypes.size ()) {
220
+ // If parameter has a default - continue matching,
221
+ // all of the subsequence parameters should have defaults
222
+ // as well, if they don't the overload choice in not viable.
223
+ if (paramListInfo.hasDefaultArgument (i))
224
+ continue ;
225
+
226
+ // Early return because this overload choice is not viable
227
+ // without default value for the current parameter.
228
+ return ;
229
+ }
230
+
216
231
if (candidateArgumentTypes[i].empty ())
217
232
continue ;
218
233
219
- const auto ¶m = overloadType->getParams ()[i];
220
234
const auto paramFlags = param.getParameterFlags ();
221
235
222
236
// If parameter is variadic we cannot compare because we don't know
Original file line number Diff line number Diff line change @@ -450,3 +450,11 @@ struct HasIntInit {
450
450
func compare_solutions_with_bindings( x: UInt8 , y: UInt8 ) -> HasIntInit {
451
451
return . init( Int ( x / numericCast( y) ) )
452
452
}
453
+
454
+ // Test to make sure that previous favoring behavior is maintained and @autoclosure makes a difference.
455
+ func test_no_ambiguity_with_autoclosure( x: Int ) {
456
+ func test( _ condition: Bool , file: StaticString = #file, line: UInt = #line) { }
457
+ func test( _ condition: @autoclosure ( ) -> Bool , file: StaticString = #file, line: UInt = #line) { }
458
+
459
+ test ( x >= 0 ) // Ok
460
+ }
You can’t perform that action at this time.
0 commit comments