@@ -1667,6 +1667,14 @@ RValueEmitter::visitPackExpansionExpr(PackExpansionExpr *E,
16671667
16681668RValue
16691669RValueEmitter::visitPackElementExpr (PackElementExpr *E, SGFContext C) {
1670+ // If this is a captured pack element reference, just emit the parameter value
1671+ // that was passed to the closure.
1672+ auto found = SGF.OpaqueValues .find (E);
1673+ if (found != SGF.OpaqueValues .end ())
1674+ return RValue (SGF, E, SGF.manageOpaqueValue (found->second , E, C));
1675+
1676+ // Otherwise, we're going to project the address of an element from the pack
1677+ // itself.
16701678 FormalEvaluationScope scope (SGF);
16711679
16721680 LValue lv = SGF.emitLValue (E, SGFAccessKind::OwnedObjectRead);
@@ -5972,9 +5980,9 @@ RValue RValueEmitter::visitMakeTemporarilyEscapableExpr(
59725980}
59735981
59745982RValue RValueEmitter::visitOpaqueValueExpr (OpaqueValueExpr *E, SGFContext C) {
5975- assert ( SGF.OpaqueValues .count (E) && " Didn't bind OpaqueValueExpr " );
5976- auto value = SGF.OpaqueValues [E] ;
5977- return RValue (SGF, E, SGF.manageOpaqueValue (value , E, C));
5983+ auto found = SGF.OpaqueValues .find (E );
5984+ assert (found ! = SGF.OpaqueValues . end ()) ;
5985+ return RValue (SGF, E, SGF.manageOpaqueValue (found-> second , E, C));
59785986}
59795987
59805988RValue RValueEmitter::visitPropertyWrapperValuePlaceholderExpr (
0 commit comments