@@ -2111,13 +2111,17 @@ static void eraseOpenedExistentials(Expr *&expr, ConstraintSystem &CS) {
2111
2111
// Walk the base expression to ensure we erase any existentials within
2112
2112
// it.
2113
2113
base = base->walk (*this );
2114
-
2115
- bool inserted = OpenExistentials.insert ({archetypeVal, base}).second ;
2116
- assert (inserted && " OpaqueValue appears multiple times?" );
2117
- (void )inserted;
2114
+
2115
+ registerOpaqueValue (archetypeVal, base);
2118
2116
return { true , OOE->getSubExpr () };
2119
2117
}
2120
-
2118
+
2119
+ if (auto *MTEE = dyn_cast<MakeTemporarilyEscapableExpr>(expr)) {
2120
+ registerOpaqueValue (MTEE->getOpaqueValue (),
2121
+ MTEE->getNonescapingClosureValue ());
2122
+ return {true , MTEE->getSubExpr ()};
2123
+ }
2124
+
2121
2125
if (auto OVE = dyn_cast<OpaqueValueExpr>(expr)) {
2122
2126
auto value = OpenExistentials.find (OVE);
2123
2127
assert (value != OpenExistentials.end () &&
@@ -2166,6 +2170,12 @@ static void eraseOpenedExistentials(Expr *&expr, ConstraintSystem &CS) {
2166
2170
std::pair<bool , Stmt *> walkToStmtPre (Stmt *S) override {
2167
2171
return { false , S };
2168
2172
}
2173
+
2174
+ void registerOpaqueValue (OpaqueValueExpr *opaque, Expr *base) {
2175
+ bool inserted = OpenExistentials.insert ({opaque, base}).second ;
2176
+ assert (inserted && " OpaqueValue appears multiple times?" );
2177
+ (void )inserted;
2178
+ }
2169
2179
};
2170
2180
2171
2181
expr = expr->walk (ExistentialEraser (CS));
0 commit comments