File tree Expand file tree Collapse file tree 2 files changed +15
-16
lines changed Expand file tree Collapse file tree 2 files changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -1296,21 +1296,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
1296
1296
}
1297
1297
}
1298
1298
1299
- // Let's check whether this is a situation when callee expects
1300
- // no arguments but N are given. Otherwise, just below
1301
- // `typeCheckArgumentChild*` is going to use `()` is a contextual type which
1302
- // is incorrect.
1303
- if (argType && argType->isVoid ()) {
1304
- auto *argExpr = callExpr->getArg ();
1305
- if (isa<ParenExpr>(argExpr) ||
1306
- (isa<TupleExpr>(argExpr) &&
1307
- cast<TupleExpr>(argExpr)->getNumElements () > 0 )) {
1308
- diagnose (callExpr->getLoc (), diag::extra_argument_to_nullary_call)
1309
- .highlight (argExpr->getSourceRange ());
1310
- return true ;
1311
- }
1312
- }
1313
-
1314
1299
// Get the expression result of type checking the arguments to the call
1315
1300
// independently, so we have some idea of what we're working with.
1316
1301
//
Original file line number Diff line number Diff line change @@ -4561,7 +4561,21 @@ bool ExtraneousArgumentsFailure::diagnoseAsNote() {
4561
4561
}
4562
4562
4563
4563
bool ExtraneousArgumentsFailure::diagnoseSingleExtraArgument () const {
4564
- auto *arguments = getArgumentListExprFor (getLocator ());
4564
+ auto *locator = getLocator ();
4565
+
4566
+ // This specifically handles a case of `Void(...)` which generates
4567
+ // constraints differently from other constructor invocations and
4568
+ // wouldn't have `ApplyArgument` as a last element in the locator.
4569
+ if (auto *call = dyn_cast<CallExpr>(getRawAnchor ())) {
4570
+ auto *TE = dyn_cast<TypeExpr>(call->getFn ());
4571
+ if (TE && getType (TE)->getMetatypeInstanceType ()->isVoid ()) {
4572
+ emitDiagnostic (call->getLoc (), diag::extra_argument_to_nullary_call)
4573
+ .highlight (call->getArg ()->getSourceRange ());
4574
+ return true ;
4575
+ }
4576
+ }
4577
+
4578
+ auto *arguments = getArgumentListExprFor (locator);
4565
4579
if (!arguments)
4566
4580
return false ;
4567
4581
You can’t perform that action at this time.
0 commit comments