@@ -182,12 +182,6 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
182
182
return type;
183
183
}
184
184
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
-
191
185
// / Attempt to diagnose a specific failure from the info we've collected from
192
186
// / the failed constraint system.
193
187
bool diagnoseExprFailure ();
@@ -918,48 +912,6 @@ static Expr *getFailedArgumentExpr(CalleeCandidateInfo CCI, Expr *argExpr) {
918
912
}
919
913
}
920
914
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
-
963
915
bool FailureDiagnosis::visitApplyExpr (ApplyExpr *callExpr) {
964
916
auto *fnExpr = callExpr->getFn ();
965
917
auto fnType = CS.getType (fnExpr)->getRValueType ();
@@ -997,9 +949,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
997
949
SmallVector<Identifier, 2 > argLabelsScratch;
998
950
ArrayRef<Identifier> argLabels =
999
951
callExpr->getArgumentLabels (argLabelsScratch);
1000
- if (diagnoseParameterErrors (calleeInfo, callExpr->getFn (),
1001
- callExpr->getArg (), argLabels))
1002
- return true ;
1003
952
1004
953
Type argType; // argument list, if known.
1005
954
if (auto FTy = fnType->getAs <AnyFunctionType>()) {
@@ -1025,10 +974,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
1025
974
1026
975
calleeInfo.filterListArgs (decomposeArgType (CS.getType (argExpr), argLabels));
1027
976
1028
- if (diagnoseParameterErrors (calleeInfo, callExpr->getFn (), argExpr,
1029
- argLabels))
1030
- return true ;
1031
-
1032
977
// Force recheck of the arg expression because we allowed unresolved types
1033
978
// before, and that turned out not to help, and now we want any diagnoses
1034
979
// from disallowing them.
0 commit comments