File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -3581,6 +3581,25 @@ bool MissingArgumentsFailure::diagnoseAsError() {
3581
3581
if (auto *closure = dyn_cast<ClosureExpr>(anchor))
3582
3582
return diagnoseClosure (closure);
3583
3583
3584
+ // This is a situation where function type is passed as an argument
3585
+ // to a function type parameter and their argument arity is different.
3586
+ //
3587
+ // ```
3588
+ // func foo(_: (Int) -> Void) {}
3589
+ // func bar() {}
3590
+ //
3591
+ // foo(bar) // `() -> Void` vs. `(Int) -> Void`
3592
+ // ```
3593
+ if (locator->isLastElement (ConstraintLocator::ApplyArgToParam)) {
3594
+ auto info = *getFunctionArgApplyInfo (locator);
3595
+
3596
+ auto *argExpr = info.getArgExpr ();
3597
+ emitDiagnostic (argExpr->getLoc (), diag::cannot_convert_argument_value,
3598
+ info.getArgType (), info.getParamType ());
3599
+ // TODO: It would be great so somehow point out which arguments are missing.
3600
+ return true ;
3601
+ }
3602
+
3584
3603
return false ;
3585
3604
}
3586
3605
You can’t perform that action at this time.
0 commit comments