@@ -170,7 +170,7 @@ void ASTPrinter::_addDeclPathRec(const DeclRef<Decl>& declRef, Index depth)
170
170
// signature
171
171
if (parentGenericDeclRef &&
172
172
!declRef.as <GenericValueParamDecl>() &&
173
- !declRef.as <GenericTypeParamDecl >())
173
+ !declRef.as <GenericTypeParamDeclBase >())
174
174
{
175
175
auto substArgs = tryGetGenericArguments (SubstitutionSet (declRef), parentGenericDeclRef.getDecl ());
176
176
if (substArgs.getCount ())
@@ -250,6 +250,16 @@ void ASTPrinter::addGenericParams(const DeclRef<GenericDecl>& genericDeclRef)
250
250
addType (getType (m_astBuilder, genericValParam));
251
251
}
252
252
}
253
+ else if (auto genericTypePackParam = paramDeclRef.as <GenericTypePackParamDecl>())
254
+ {
255
+ if (!first) sb << " , " ;
256
+ first = false ;
257
+ {
258
+ ScopePart scopePart (this , Part::Type::GenericParamType);
259
+ sb << " each " ;
260
+ sb << getText (genericTypePackParam.getName ());
261
+ }
262
+ }
253
263
else
254
264
{
255
265
}
@@ -269,57 +279,73 @@ void ASTPrinter::addDeclParams(const DeclRef<Decl>& declRef, List<Range<Index>>*
269
279
bool first = true ;
270
280
for (auto paramDeclRef : getParameters (m_astBuilder, funcDeclRef))
271
281
{
272
- if (!first) sb << " , " ;
273
-
274
282
auto rangeStart = sb.getLength ();
275
283
276
284
ParamDecl* paramDecl = paramDeclRef.getDecl ();
285
+ auto paramType = getType (m_astBuilder, paramDeclRef);
277
286
287
+ auto addParamElement = [&](Type* type, Index elementIndex)
278
288
{
279
- ScopePart scopePart (this , Part::Type::ParamType);
280
-
281
- // Seems these apply to parameters/VarDeclBase and are not part of the 'type'
282
- // but seems more appropriate to put in the Type Part
289
+ if (!first) sb << " , " ;
283
290
284
- if (paramDecl->hasModifier <InOutModifier>())
285
- {
286
- sb << toSlice (" inout " );
287
- }
288
- else if (paramDecl->hasModifier <OutModifier>())
291
+ // Type part.
289
292
{
290
- sb << toSlice (" out " );
291
- }
292
- else if (paramDecl->hasModifier <InModifier>())
293
- {
294
- sb << toSlice (" in " );
293
+ ScopePart scopePart (this , Part::Type::ParamType);
294
+
295
+ // Seems these apply to parameters/VarDeclBase and are not part of the 'type'
296
+ // but seems more appropriate to put in the Type Part
297
+
298
+ if (paramDecl->hasModifier <InOutModifier>())
299
+ {
300
+ sb << toSlice (" inout " );
301
+ }
302
+ else if (paramDecl->hasModifier <OutModifier>())
303
+ {
304
+ sb << toSlice (" out " );
305
+ }
306
+ else if (paramDecl->hasModifier <InModifier>())
307
+ {
308
+ sb << toSlice (" in " );
309
+ }
310
+
311
+ // And this to params/variables (not the type)
312
+ if (paramDecl->hasModifier <ConstModifier>())
313
+ {
314
+ sb << toSlice (" const " );
315
+ }
316
+
317
+ addType (type);
295
318
}
296
319
297
- // And this to params/variables (not the type)
298
- if (paramDecl->hasModifier <ConstModifier> ())
320
+ // Output the parameter name if there is one, and it's enabled in the options
321
+ if (m_optionFlags & OptionFlag::ParamNames && paramDecl->getName ())
299
322
{
300
- sb << toSlice (" const " );
323
+ sb << " " ;
324
+ {
325
+ ScopePart scopePart (this , Part::Type::ParamName);
326
+ sb << paramDecl->getName ()->text ;
327
+ if (elementIndex != -1 )
328
+ sb << " _" << elementIndex;
329
+ }
301
330
}
302
331
303
- addType (getType (m_astBuilder, paramDeclRef));
304
- }
332
+ auto rangeEnd = sb.getLength ();
305
333
306
- // Output the parameter name if there is one, and it's enabled in the options
307
- if (m_optionFlags & OptionFlag::ParamNames && paramDecl->getName ())
334
+ if (outParamRange)
335
+ outParamRange->add (makeRange<Index>(rangeStart, rangeEnd));
336
+ first = false ;
337
+ };
338
+ if (auto typePack = as<ConcreteTypePack>(paramType))
308
339
{
309
- sb << " " ;
310
-
340
+ for (Index elementIndex = 0 ; elementIndex < typePack->getTypeCount (); ++elementIndex)
311
341
{
312
- ScopePart scopePart (this , Part::Type::ParamName);
313
- sb << paramDecl->getName ()->text ;
342
+ addParamElement (typePack->getElementType (elementIndex), elementIndex);
314
343
}
315
344
}
316
-
317
- auto rangeEnd = sb.getLength ();
318
-
319
- if (outParamRange)
320
- outParamRange->add (makeRange<Index>(rangeStart, rangeEnd));
321
-
322
- first = false ;
345
+ else
346
+ {
347
+ addParamElement (paramType, -1 );
348
+ }
323
349
}
324
350
325
351
sb << " )" ;
0 commit comments