Skip to content

Commit b405f7c

Browse files
committed
[Diagnostics] Avoid direct use of constraint system by MissingArgumentsFailure::isMisplacedMissingArgument
1 parent db6801b commit b405f7c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,12 +4264,11 @@ bool MissingArgumentsFailure::isMisplacedMissingArgument(
42644264
return (*fix)->getKind() == kind;
42654265
};
42664266

4267-
auto &cs = solution.getConstraintSystem();
42684267
auto *callLocator =
4269-
cs.getConstraintLocator(anchor, ConstraintLocator::ApplyArgument);
4268+
solution.getConstraintLocator(anchor, {ConstraintLocator::ApplyArgument});
42704269

42714270
auto argFlags = fnType->getParams()[0].getParameterFlags();
4272-
auto *argLoc = cs.getConstraintLocator(
4271+
auto *argLoc = solution.getConstraintLocator(
42734272
callLocator, LocatorPathElt::ApplyArgToParam(0, 0, argFlags));
42744273

42754274
if (!(hasFixFor(FixKind::AllowArgumentTypeMismatch, argLoc) &&
@@ -4298,7 +4297,7 @@ bool MissingArgumentsFailure::isMisplacedMissingArgument(
42984297
auto argType = solution.simplifyType(solution.getType(argument));
42994298
auto paramType = fnType->getParams()[1].getPlainType();
43004299

4301-
return TypeChecker::isConvertibleTo(argType, paramType, cs.DC);
4300+
return TypeChecker::isConvertibleTo(argType, paramType, solution.getDC());
43024301
}
43034302

43044303
std::tuple<Expr *, Expr *, unsigned, bool>

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,8 @@ size_t Solution::getTotalMemory() const {
25092509
Conformances.size() * sizeof(std::pair<ConstraintLocator *, ProtocolConformanceRef>);
25102510
}
25112511

2512+
DeclContext *Solution::getDC() const { return constraintSystem->DC; }
2513+
25122514
DeclName OverloadChoice::getName() const {
25132515
switch (getKind()) {
25142516
case OverloadChoiceKind::Decl:

lib/Sema/ConstraintSystem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ class Solution {
885885
/// Retrieve the constraint system that this solution solves.
886886
ConstraintSystem &getConstraintSystem() const { return *constraintSystem; }
887887

888+
DeclContext *getDC() const;
889+
888890
/// The set of type bindings.
889891
llvm::DenseMap<TypeVariableType *, Type> typeBindings;
890892

0 commit comments

Comments
 (0)