@@ -658,7 +658,7 @@ class BuilderClosureRewriter
658
658
auto recorded = found->second ;
659
659
if (auto temporaryVar = recorded.temporaryVar ) {
660
660
Type type = solution.simplifyType (solution.getType (temporaryVar));
661
- temporaryVar->setInterfaceType (type);
661
+ temporaryVar->setInterfaceType (type-> mapTypeOutOfContext () );
662
662
}
663
663
664
664
// Erase the captured expression, so we're sure we never do this twice.
@@ -676,7 +676,7 @@ class BuilderClosureRewriter
676
676
// Set the type of the temporary variable.
677
677
auto temporaryVar = found->second .first ;
678
678
Type type = solution.simplifyType (solution.getType (temporaryVar));
679
- temporaryVar->setInterfaceType (type);
679
+ temporaryVar->setInterfaceType (type-> mapTypeOutOfContext () );
680
680
681
681
// Take the expressions.
682
682
auto exprs = std::move (found->second .second );
@@ -849,6 +849,13 @@ class BuilderClosureRewriter
849
849
auto cond = ifStmt->getCond ();
850
850
auto condExpr = cond.front ().getBoolean ();
851
851
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
+
852
859
cond.front ().setBoolean (finalCondExpr);
853
860
ifStmt->setCond (cond);
854
861
0 commit comments