@@ -220,28 +220,35 @@ Optional<unsigned> ArgumentList::findArgumentExpr(Expr *expr,
220
220
Expr *ArgumentList::packIntoImplicitTupleOrParen (
221
221
ASTContext &ctx, llvm::function_ref<Type(Expr *)> getType) const {
222
222
assert (!hasAnyInOutArgs () && " Cannot construct bare tuple/paren with inout" );
223
+
224
+ // Make sure to preserve the source location info here and below as it may be
225
+ // needed for e.g serialization of its textual representation.
223
226
if (auto *unary = getUnlabeledUnaryExpr ()) {
224
- auto *paren = new (ctx) ParenExpr (SourceLoc (), unary, SourceLoc ());
227
+ auto *paren = new (ctx) ParenExpr (getLParenLoc (), unary, getRParenLoc ());
225
228
if (auto ty = getType (unary))
226
229
paren->setType (ParenType::get (ctx, ty));
227
230
paren->setImplicit ();
228
231
return paren;
229
232
}
230
233
231
- SmallVector<Expr *, 8 > argExprs;
232
- SmallVector<Identifier, 8 > argLabels;
233
- SmallVector<TupleTypeElt, 8 > tupleEltTypes;
234
+ SmallVector<Expr *, 2 > argExprs;
235
+ SmallVector<Identifier, 2 > argLabels;
236
+ SmallVector<SourceLoc, 2 > argLabelLocs;
237
+ SmallVector<TupleTypeElt, 2 > tupleEltTypes;
234
238
235
239
for (auto arg : *this ) {
236
240
auto *argExpr = arg.getExpr ();
237
241
argExprs.push_back (argExpr);
238
242
argLabels.push_back (arg.getLabel ());
243
+ argLabelLocs.push_back (arg.getLabelLoc ());
239
244
if (auto ty = getType (argExpr))
240
245
tupleEltTypes.emplace_back (ty, arg.getLabel ());
241
246
}
242
247
assert (tupleEltTypes.empty () || tupleEltTypes.size () == argExprs.size ());
243
248
244
- auto *tuple = TupleExpr::createImplicit (ctx, argExprs, argLabels);
249
+ auto *tuple =
250
+ TupleExpr::create (ctx, getLParenLoc (), argExprs, argLabels, argLabelLocs,
251
+ getRParenLoc (), /* implicit*/ true );
245
252
if (empty () || !tupleEltTypes.empty ())
246
253
tuple->setType (TupleType::get (tupleEltTypes, ctx));
247
254
0 commit comments