Skip to content

Commit aaae13e

Browse files
committed
[CSDiag] NFC: Remove obsolete diagnoseTupleParameterMismatch
1 parent 9550d10 commit aaae13e

File tree

1 file changed

+0
-114
lines changed

1 file changed

+0
-114
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,116 +3044,6 @@ bool FailureDiagnosis::diagnoseImplicitSelfErrors(
30443044
return false;
30453045
}
30463046

3047-
static bool diagnoseTupleParameterMismatch(CalleeCandidateInfo &CCI,
3048-
ArrayRef<AnyFunctionType::Param> params,
3049-
ArrayRef<AnyFunctionType::Param> args,
3050-
Expr *fnExpr, Expr *argExpr,
3051-
bool isTopLevel = true) {
3052-
// Try to diagnose function call tuple parameter splat only if
3053-
// there is no trailing or argument closure, because
3054-
// FailureDiagnosis::visitClosureExpr will produce better
3055-
// diagnostic and fix-it for trailing closure case.
3056-
if (isTopLevel) {
3057-
if (CCI.hasTrailingClosure)
3058-
return false;
3059-
3060-
if (auto *parenExpr = dyn_cast<ParenExpr>(argExpr)) {
3061-
if (isa<ClosureExpr>(parenExpr->getSubExpr()))
3062-
return false;
3063-
}
3064-
}
3065-
3066-
if (params.size() == 1 && args.size() == 1) {
3067-
auto paramType = params.front().getOldType();
3068-
auto argType = args.front().getOldType();
3069-
3070-
if (auto *paramFnType = paramType->getAs<AnyFunctionType>()) {
3071-
// Only if both of the parameter and argument types are functions
3072-
// let's recur into diagnosing their arguments.
3073-
if (auto *argFnType = argType->getAs<AnyFunctionType>())
3074-
return diagnoseTupleParameterMismatch(CCI, paramFnType->getParams(),
3075-
argFnType->getParams(), fnExpr,
3076-
argExpr, /* isTopLevel */ false);
3077-
return false;
3078-
}
3079-
}
3080-
3081-
if (params.size() != 1 || args.empty())
3082-
return false;
3083-
3084-
auto paramType = params.front().getOldType();
3085-
3086-
if (args.size() == 1) {
3087-
auto argType = args.front().getOldType();
3088-
if (auto *paramFnType = paramType->getAs<AnyFunctionType>()) {
3089-
// Only if both of the parameter and argument types are functions
3090-
// let's recur into diagnosing their arguments.
3091-
if (auto *argFnType = argType->getAs<AnyFunctionType>())
3092-
return diagnoseTupleParameterMismatch(CCI, paramFnType->getParams(),
3093-
argFnType->getParams(), fnExpr,
3094-
argExpr, /* isTopLevel */ false);
3095-
}
3096-
3097-
return false;
3098-
}
3099-
3100-
// Let's see if inferred argument is actually a tuple inside of Paren.
3101-
auto *paramTupleTy = paramType->getAs<TupleType>();
3102-
if (!paramTupleTy)
3103-
return false;
3104-
3105-
if (paramTupleTy->getNumElements() != args.size())
3106-
return false;
3107-
3108-
// Looks like the number of tuple elements matches number
3109-
// of function arguments, which means we can we can emit an
3110-
// error about an attempt to make use of tuple splat or tuple
3111-
// destructuring, unfortunately we can't provide a fix-it for
3112-
// this case.
3113-
auto &TC = CCI.CS.TC;
3114-
if (isTopLevel) {
3115-
if (auto *decl = CCI[0].getDecl()) {
3116-
auto name = decl->getBaseName();
3117-
auto diagnostic =
3118-
name.isSpecial()
3119-
? TC.diagnose(argExpr->getLoc(),
3120-
diag::single_tuple_parameter_mismatch_special,
3121-
decl->getDescriptiveKind(), paramType)
3122-
: TC.diagnose(argExpr->getLoc(),
3123-
diag::single_tuple_parameter_mismatch_normal,
3124-
decl->getDescriptiveKind(), name, paramType);
3125-
3126-
diagnostic.highlight(argExpr->getSourceRange())
3127-
.fixItInsertAfter(argExpr->getStartLoc(), "(")
3128-
.fixItInsert(argExpr->getEndLoc(), ")");
3129-
} else {
3130-
TC.diagnose(argExpr->getLoc(),
3131-
diag::unknown_single_tuple_parameter_mismatch, paramTupleTy)
3132-
.highlight(argExpr->getSourceRange())
3133-
.fixItInsertAfter(argExpr->getStartLoc(), "(")
3134-
.fixItInsert(argExpr->getEndLoc(), ")");
3135-
}
3136-
} else {
3137-
TC.diagnose(argExpr->getLoc(),
3138-
diag::nested_tuple_parameter_destructuring, paramTupleTy,
3139-
CCI.CS.getType(fnExpr));
3140-
}
3141-
3142-
return true;
3143-
}
3144-
3145-
static bool diagnoseTupleParameterMismatch(CalleeCandidateInfo &CCI,
3146-
ArrayRef<FunctionType::Param> params,
3147-
Type argType, Expr *fnExpr,
3148-
Expr *argExpr,
3149-
bool isTopLevel = true) {
3150-
llvm::SmallVector<AnyFunctionType::Param, 4> args;
3151-
FunctionType::decomposeInput(argType, args);
3152-
3153-
return diagnoseTupleParameterMismatch(CCI, params, args, fnExpr, argExpr,
3154-
isTopLevel);
3155-
}
3156-
31573047
class ArgumentMatcher : public MatchCallArgumentListener {
31583048
TypeChecker &TC;
31593049
Expr *FnExpr;
@@ -3469,10 +3359,6 @@ diagnoseSingleCandidateFailures(CalleeCandidateInfo &CCI, Expr *fnExpr,
34693359
}
34703360
}
34713361

3472-
if (diagnoseTupleParameterMismatch(CCI, candidate.getParameters(),
3473-
CCI.CS.getType(argExpr), fnExpr, argExpr))
3474-
return true;
3475-
34763362
// We only handle structural errors here.
34773363
if (CCI.closeness != CC_ArgumentLabelMismatch &&
34783364
CCI.closeness != CC_ArgumentCountMismatch)

0 commit comments

Comments
 (0)