File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -4092,11 +4092,23 @@ bool ConstraintSystem::repairFailures(
40924092 path.pop_back ();
40934093 // If this is a contextual mismatch between l-value types e.g.
40944094 // `@lvalue String vs. @lvalue Int`, let's pretend that it's okay.
4095- if (!path.empty () && path.back ().is <LocatorPathElt::ContextualType>()) {
4096- auto *locator = getConstraintLocator (anchor, path.back ());
4097- conversionsOrFixes.push_back (
4098- IgnoreContextualType::create (*this , lhs, rhs, locator));
4099- break ;
4095+ if (!path.empty ()) {
4096+ if (path.back ().is <LocatorPathElt::ContextualType>()) {
4097+ auto *locator = getConstraintLocator (anchor, path.back ());
4098+ conversionsOrFixes.push_back (
4099+ IgnoreContextualType::create (*this , lhs, rhs, locator));
4100+ break ;
4101+ }
4102+
4103+ // If this is a function type param type mismatch in any position,
4104+ // the mismatch we want to report is for the whole structural type.
4105+ auto last = std::find_if (
4106+ path.rbegin (), path.rend (), [](LocatorPathElt &elt) -> bool {
4107+ return elt.is <LocatorPathElt::FunctionArgument>();
4108+ });
4109+
4110+ if (last != path.rend ())
4111+ break ;
41004112 }
41014113
41024114 LLVM_FALLTHROUGH;
You can’t perform that action at this time.
0 commit comments