[ConstraintSystem] Allow function mismatch in assignment to be diagnosed

This commit is contained in:
Pavel Yaskevich
2019-10-30 10:01:58 -07:00
parent 4eaf159eab
commit 97773baf71
2 changed files with 15 additions and 3 deletions

View File

@@ -3768,7 +3768,19 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
case TypeKind::Function: {
auto func1 = cast<FunctionType>(desugar1);
auto func2 = cast<FunctionType>(desugar2);
return matchFunctionTypes(func1, func2, kind, flags, locator);
auto result = matchFunctionTypes(func1, func2, kind, flags, locator);
// If this is a type mismatch in assignment, we don't really care
// (yet) was it argument or result type mismatch, let's produce a
// diagnostic which means both function types.
if (shouldAttemptFixes() && result.isFailure()) {
auto *anchor = locator.getAnchor();
if (anchor && isa<AssignExpr>(anchor))
break;
}
return result;
}
case TypeKind::GenericFunction: