[Diagnostics] Improve argument labeling diagnostics

Extend new labeling diagnostics (via fixes) to support
member references and subscripts.
This commit is contained in:
Pavel Yaskevich
2019-02-21 16:03:03 -08:00
parent 1a66c77110
commit d4b67bf3f7
10 changed files with 53 additions and 19 deletions

View File

@@ -366,10 +366,25 @@ bool MissingConformanceFailure::diagnoseAsError() {
bool LabelingFailure::diagnoseAsError() {
auto &cs = getConstraintSystem();
auto *call = cast<CallExpr>(getAnchor());
return diagnoseArgumentLabelError(cs.getASTContext(), call->getArg(),
CorrectLabels,
isa<SubscriptExpr>(call->getFn()));
auto *anchor = getRawAnchor();
Expr *argExpr = nullptr;
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(anchor)) {
if (auto *call = dyn_cast_or_null<CallExpr>(findParentExpr(UDE)))
argExpr = call->getArg();
} else if (auto *UME = dyn_cast<UnresolvedMemberExpr>(anchor)) {
argExpr = UME->getArgument();
} else if (auto *call = dyn_cast<CallExpr>(anchor)) {
argExpr = call->getArg();
} else if (auto *SE = dyn_cast<SubscriptExpr>(anchor)) {
argExpr = SE->getIndex();
}
if (!argExpr)
return false;
return diagnoseArgumentLabelError(cs.getASTContext(), argExpr, CorrectLabels,
isa<SubscriptExpr>(anchor));
}
bool NoEscapeFuncToTypeConversionFailure::diagnoseAsError() {