Skip to content

Commit a5485d8

Browse files
committed
[CSSimplify] Detect missing optional unwraps in operator/call arguments
1 parent 7d4b72f commit a5485d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,16 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
19251925

19261926
auto &elt = path.back();
19271927
switch (elt.getKind()) {
1928+
case ConstraintLocator::LValueConversion:
1929+
case ConstraintLocator::ApplyArgToParam: {
1930+
if (lhs->getOptionalObjectType() && !rhs->getOptionalObjectType()) {
1931+
conversionsOrFixes.push_back(
1932+
ForceOptional::create(cs, lhs, lhs->getOptionalObjectType(),
1933+
cs.getConstraintLocator(locator)));
1934+
}
1935+
break;
1936+
}
1937+
19281938
case ConstraintLocator::FunctionArgument: {
19291939
auto *argLoc = cs.getConstraintLocator(
19301940
locator.withPathElement(LocatorPathElt::getSynthesizedArgument(0)));

0 commit comments

Comments
 (0)