[ConstraintSystem] Handle assignment to AnyObject as a contextual type mismatch

Contextual diagnostics already have a special case for `AnyObject`
conversions which is going to be diagnosed as a missing conformance.
This commit is contained in:
Pavel Yaskevich
2019-10-25 13:33:16 -07:00
parent 723e438c78
commit d23adafd3c

View File

@@ -2686,6 +2686,15 @@ bool ConstraintSystem::repairFailures(
if (repairViaBridgingCast(*this, lhs, rhs, conversionsOrFixes, locator))
return true;
// If destination is `AnyObject` it means that source doesn't conform.
if (rhs->getWithoutSpecifierType()
->lookThroughAllOptionalTypes()
->isAnyObject()) {
conversionsOrFixes.push_back(IgnoreAssignmentDestinationType::create(
*this, lhs, rhs, getConstraintLocator(locator)));
return true;
}
// If we are trying to assign e.g. `Array<Int>` to `Array<Float>` let's
// give solver a chance to determine which generic parameters are
// mismatched and produce a fix for that.