Skip to content

Commit b375c09

Browse files
[Diagnostic] Fix regression in requirement diagnostics
1 parent 4ebedc8 commit b375c09

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ ValueDecl *RequirementFailure::getDeclRef() const {
282282
return getAffectedDeclFromType(contextualTy);
283283
}
284284

285+
if (getLocator()->isFirstElement<LocatorPathElt::CoercionOperand>())
286+
return getAffectedDeclFromType(getOwnerType());
287+
285288
if (auto overload = getCalleeOverloadChoiceIfAvailable(getLocator())) {
286289
// If there is a declaration associated with this
287290
// failure e.g. an overload choice of the call

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,9 +3329,8 @@ namespace {
33293329
// bindings for the result of the coercion.
33303330
if (repr &&
33313331
repr->getKind() == TypeReprKind::ImplicitlyUnwrappedOptional) {
3332-
auto *locatorIUO = CS.getConstraintLocator(expr);
3333-
return createTypeVariableAndDisjunctionForIUOCoercion(toType,
3334-
locatorIUO);
3332+
return createTypeVariableAndDisjunctionForIUOCoercion(
3333+
toType, CS.getConstraintLocator(expr));
33353334
}
33363335

33373336
return toType;

0 commit comments

Comments
 (0)