Skip to content

Commit cf96e65

Browse files
committed
[Function builders] Minor fixes for lvalue-ness, interface types
1 parent 9853926 commit cf96e65

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class BuilderClosureRewriter
658658
auto recorded = found->second;
659659
if (auto temporaryVar = recorded.temporaryVar) {
660660
Type type = solution.simplifyType(solution.getType(temporaryVar));
661-
temporaryVar->setInterfaceType(type);
661+
temporaryVar->setInterfaceType(type->mapTypeOutOfContext());
662662
}
663663

664664
// Erase the captured expression, so we're sure we never do this twice.
@@ -676,7 +676,7 @@ class BuilderClosureRewriter
676676
// Set the type of the temporary variable.
677677
auto temporaryVar = found->second.first;
678678
Type type = solution.simplifyType(solution.getType(temporaryVar));
679-
temporaryVar->setInterfaceType(type);
679+
temporaryVar->setInterfaceType(type->mapTypeOutOfContext());
680680

681681
// Take the expressions.
682682
auto exprs = std::move(found->second.second);
@@ -849,6 +849,13 @@ class BuilderClosureRewriter
849849
auto cond = ifStmt->getCond();
850850
auto condExpr = cond.front().getBoolean();
851851
auto finalCondExpr = rewriteExpr(condExpr);
852+
853+
// Load the condition if needed.
854+
if (finalCondExpr->getType()->is<LValueType>()) {
855+
auto &cs = solution.getConstraintSystem();
856+
finalCondExpr = cs.addImplicitLoadExpr(finalCondExpr);
857+
}
858+
852859
cond.front().setBoolean(finalCondExpr);
853860
ifStmt->setCond(cond);
854861

0 commit comments

Comments
 (0)