Skip to content

Commit cc29dc5

Browse files
[CSDiag] Removing diagnose parameter error from CSDiag
1 parent 5572832 commit cc29dc5

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
182182
return type;
183183
}
184184

185-
/// Diagnose common failures due to applications of an argument list to an
186-
/// ApplyExpr or SubscriptExpr.
187-
bool diagnoseParameterErrors(CalleeCandidateInfo &CCI,
188-
Expr *fnExpr, Expr *argExpr,
189-
ArrayRef<Identifier> argLabels);
190-
191185
/// Attempt to diagnose a specific failure from the info we've collected from
192186
/// the failed constraint system.
193187
bool diagnoseExprFailure();
@@ -918,48 +912,6 @@ static Expr *getFailedArgumentExpr(CalleeCandidateInfo CCI, Expr *argExpr) {
918912
}
919913
}
920914

921-
/// If the candidate set has been narrowed down to a specific structural
922-
/// problem, e.g. that there are too few parameters specified or that argument
923-
/// labels don't match up, diagnose that error and return true.
924-
bool FailureDiagnosis::diagnoseParameterErrors(CalleeCandidateInfo &CCI,
925-
Expr *fnExpr, Expr *argExpr,
926-
ArrayRef<Identifier> argLabels) {
927-
// If we have a failure where the candidate set differs on exactly one
928-
// argument, and where we have a consistent mismatch across the candidate set
929-
// (often because there is only one candidate in the set), then diagnose this
930-
// as a specific problem of passing something of the wrong type into a
931-
// parameter.
932-
//
933-
// We don't generally want to use this path to diagnose calls to
934-
// symmetrically-typed binary operators because it's likely that both
935-
// operands contributed to the type.
936-
if ((CCI.closeness == CC_OneArgumentMismatch ||
937-
CCI.closeness == CC_OneArgumentNearMismatch ||
938-
CCI.closeness == CC_OneGenericArgumentMismatch ||
939-
CCI.closeness == CC_OneGenericArgumentNearMismatch ||
940-
CCI.closeness == CC_GenericNonsubstitutableMismatch) &&
941-
CCI.failedArgument.isValid() &&
942-
!isSymmetricBinaryOperator(CCI)) {
943-
// Map the argument number into an argument expression.
944-
TCCOptions options = TCC_ForceRecheck;
945-
if (CCI.failedArgument.parameterType->is<InOutType>())
946-
options |= TCC_AllowLValue;
947-
948-
// It could be that the argument doesn't conform to an archetype.
949-
Expr *badArgExpr = getFailedArgumentExpr(CCI, argExpr);
950-
951-
// Re-type-check the argument with the expected type of the candidate set.
952-
// This should produce a specific and tailored diagnostic saying that the
953-
// type mismatches with expectations.
954-
Type paramType = CCI.failedArgument.parameterType;
955-
if (!typeCheckChildIndependently(badArgExpr, paramType,
956-
CTP_CallArgument, options))
957-
return true;
958-
}
959-
960-
return false;
961-
}
962-
963915
bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
964916
auto *fnExpr = callExpr->getFn();
965917
auto fnType = CS.getType(fnExpr)->getRValueType();
@@ -997,9 +949,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
997949
SmallVector<Identifier, 2> argLabelsScratch;
998950
ArrayRef<Identifier> argLabels =
999951
callExpr->getArgumentLabels(argLabelsScratch);
1000-
if (diagnoseParameterErrors(calleeInfo, callExpr->getFn(),
1001-
callExpr->getArg(), argLabels))
1002-
return true;
1003952

1004953
Type argType; // argument list, if known.
1005954
if (auto FTy = fnType->getAs<AnyFunctionType>()) {
@@ -1025,10 +974,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
1025974

1026975
calleeInfo.filterListArgs(decomposeArgType(CS.getType(argExpr), argLabels));
1027976

1028-
if (diagnoseParameterErrors(calleeInfo, callExpr->getFn(), argExpr,
1029-
argLabels))
1030-
return true;
1031-
1032977
// Force recheck of the arg expression because we allowed unresolved types
1033978
// before, and that turned out not to help, and now we want any diagnoses
1034979
// from disallowing them.

0 commit comments

Comments
 (0)