Skip to content

Commit bf4c3b7

Browse files
committed
[Diagnostics] Use data from associated solution while diagnosing missing generic arguments
1 parent 2d1e408 commit bf4c3b7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5055,7 +5055,7 @@ bool MissingGenericArgumentsFailure::diagnoseForAnchor(
50555055

50565056
bool MissingGenericArgumentsFailure::diagnoseParameter(
50575057
Anchor anchor, GenericTypeParamType *GP) const {
5058-
auto &cs = getConstraintSystem();
5058+
auto &solution = getSolution();
50595059

50605060
auto loc = anchor.is<Expr *>() ? anchor.get<Expr *>()->getLoc()
50615061
: anchor.get<TypeRepr *>()->getLoc();
@@ -5065,7 +5065,7 @@ bool MissingGenericArgumentsFailure::diagnoseParameter(
50655065
// going to be completely cut off from the rest of constraint system,
50665066
// that's why we'd get two fixes in this case which is not ideal.
50675067
if (locator->isForContextualType() &&
5068-
llvm::count_if(cs.DefaultedConstraints,
5068+
llvm::count_if(solution.DefaultedConstraints,
50695069
[&GP](const ConstraintLocator *locator) {
50705070
return locator->getGenericParameter() == GP;
50715071
}) > 1) {
@@ -5105,7 +5105,7 @@ bool MissingGenericArgumentsFailure::diagnoseParameter(
51055105

51065106
void MissingGenericArgumentsFailure::emitGenericSignatureNote(
51075107
Anchor anchor) const {
5108-
auto &cs = getConstraintSystem();
5108+
auto &solution = getSolution();
51095109
auto *paramDC = getDeclContext();
51105110

51115111
if (!paramDC)
@@ -5123,7 +5123,9 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
51235123
};
51245124

51255125
llvm::SmallDenseMap<GenericTypeParamDecl *, Type> params;
5126-
for (auto *typeVar : cs.getTypeVariables()) {
5126+
for (auto &entry : solution.typeBindings) {
5127+
auto *typeVar = entry.first;
5128+
51275129
auto *GP = typeVar->getImpl().getGenericParameter();
51285130
if (!GP)
51295131
continue;
@@ -5133,7 +5135,7 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
51335135

51345136
// If this is one of the defaulted parameter types, attempt
51355137
// to emit placeholder for it instead of `Any`.
5136-
if (llvm::any_of(cs.DefaultedConstraints,
5138+
if (llvm::any_of(solution.DefaultedConstraints,
51375139
[&](const ConstraintLocator *locator) {
51385140
return GP->getDecl() == getParamDecl(locator);
51395141
}))

0 commit comments

Comments
 (0)