Skip to content

Commit f03d210

Browse files
committed
Make getFunctionArgApplyInfo more lenient with CSDiag
1 parent ec45b24 commit f03d210

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,20 @@ FailureDiagnostic::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
229229
choice = overload->choice;
230230
rawFnType = overload->openedType;
231231
} else {
232-
// If we didn't resolve an overload for the callee, we must be dealing with
233-
// a call of an arbitrary function expr.
234-
auto *call = cast<CallExpr>(anchor);
235-
assert(!shouldHaveDirectCalleeOverload(call) &&
236-
"Should we have resolved a callee for this?");
237-
rawFnType = cs.getType(call->getFn());
232+
// If we didn't resolve an overload for the callee, we should be dealing
233+
// with a call of an arbitrary function expr.
234+
if (auto *call = dyn_cast<CallExpr>(anchor)) {
235+
assert(!shouldHaveDirectCalleeOverload(call) &&
236+
"Should we have resolved a callee for this?");
237+
rawFnType = cs.getType(call->getFn());
238+
} else {
239+
// FIXME: ArgumentMismatchFailure is currently used from CSDiag, meaning
240+
// we can end up a BinaryExpr here with an unresolved callee. It should be
241+
// possible to remove this once we've gotten rid of the old CSDiag logic
242+
// and just assert that we have a CallExpr.
243+
auto *apply = cast<ApplyExpr>(anchor);
244+
rawFnType = cs.getType(apply->getFn());
245+
}
238246
}
239247

240248
// Try to resolve the function type by loading lvalues and looking through

0 commit comments

Comments
 (0)