[CSSimplify] Detect missing optional unwraps in operator/call arguments

This commit is contained in:
Pavel Yaskevich
2019-03-07 14:51:46 -08:00
parent 7d4b72ffb5
commit a5485d8ae2

View File

@@ -1925,6 +1925,16 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
auto &elt = path.back();
switch (elt.getKind()) {
case ConstraintLocator::LValueConversion:
case ConstraintLocator::ApplyArgToParam: {
if (lhs->getOptionalObjectType() && !rhs->getOptionalObjectType()) {
conversionsOrFixes.push_back(
ForceOptional::create(cs, lhs, lhs->getOptionalObjectType(),
cs.getConstraintLocator(locator)));
}
break;
}
case ConstraintLocator::FunctionArgument: {
auto *argLoc = cs.getConstraintLocator(
locator.withPathElement(LocatorPathElt::getSynthesizedArgument(0)));