@@ -6326,6 +6326,11 @@ void ExprRewriter::peepholeArrayUpcast(ArrayExpr *expr, Type toType,
6326
6326
ConstraintLocatorBuilder locator) {
6327
6327
// Update the type of the array literal.
6328
6328
cs.setType (expr, toType);
6329
+ // FIXME: finish{Array,Dictionary}Expr invoke cacheExprTypes after forming
6330
+ // the semantic expression for the dictionary literal, which will undo the
6331
+ // type we set here if this dictionary literal is nested unless we update
6332
+ // the expr type as well.
6333
+ expr->setType (toType);
6329
6334
6330
6335
// Convert the elements.
6331
6336
ConstraintLocatorBuilder innerLocator =
@@ -6350,6 +6355,11 @@ void ExprRewriter::peepholeDictionaryUpcast(DictionaryExpr *expr,
6350
6355
ConstraintLocatorBuilder locator) {
6351
6356
// Update the type of the dictionary literal.
6352
6357
cs.setType (expr, toType);
6358
+ // FIXME: finish{Array,Dictionary}Expr invoke cacheExprTypes after forming
6359
+ // the semantic expression for the dictionary literal, which will undo the
6360
+ // type we set here if this dictionary literal is nested unless we update
6361
+ // the expr type as well.
6362
+ expr->setType (toType);
6353
6363
6354
6364
ConstraintLocatorBuilder keyLocator =
6355
6365
locator.withPathElement (
@@ -6378,6 +6388,11 @@ void ExprRewriter::peepholeDictionaryUpcast(DictionaryExpr *expr,
6378
6388
}
6379
6389
6380
6390
cs.setType (tuple, tupleType);
6391
+ // FIXME: finish{Array,Dictionary}Expr invoke cacheExprTypes after forming
6392
+ // the semantic expression for the dictionary literal, which will undo the
6393
+ // type we set here if this dictionary literal is nested unless we update
6394
+ // the expr type as well.
6395
+ tuple->setType (tupleType);
6381
6396
}
6382
6397
}
6383
6398
@@ -6387,16 +6402,22 @@ void ExprRewriter::peepholeDictionaryUpcast(DictionaryExpr *expr,
6387
6402
bool ExprRewriter::peepholeCollectionUpcast (Expr *expr, Type toType,
6388
6403
bool bridged,
6389
6404
ConstraintLocatorBuilder locator) {
6390
- // Recurse into parenthesized expressions.
6405
+ // Recur into parenthesized expressions.
6391
6406
if (auto paren = dyn_cast<ParenExpr>(expr)) {
6392
6407
// If we can't peephole the subexpression, we're done.
6393
6408
if (!peepholeCollectionUpcast (paren->getSubExpr (), toType, bridged,
6394
6409
locator))
6395
6410
return false ;
6396
6411
6397
6412
// Update the type of this expression.
6398
- cs.setType (paren, ParenType::get (cs.getASTContext (),
6399
- cs.getType (paren->getSubExpr ())));
6413
+ auto parenTy = ParenType::get (cs.getASTContext (),
6414
+ cs.getType (paren->getSubExpr ()));
6415
+ cs.setType (paren, parenTy);
6416
+ // FIXME: finish{Array,Dictionary}Expr invoke cacheExprTypes after forming
6417
+ // the semantic expression for the dictionary literal, which will undo the
6418
+ // type we set here if this dictionary literal is nested unless we update
6419
+ // the expr type as well.
6420
+ paren->setType (parenTy);
6400
6421
return true ;
6401
6422
}
6402
6423
0 commit comments