Skip to content

Commit b1faf12

Browse files
authored
Move TemplateDeclaration.computeIsTrivialAlias logic to templatesem (dlang#22631)
1 parent f00d563 commit b1faf12

2 files changed

Lines changed: 38 additions & 38 deletions

File tree

compiler/src/dmd/dtemplate.d

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -299,44 +299,6 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
299299
this.visibility = Visibility(Visibility.Kind.undefined);
300300
}
301301

302-
extern(D) void computeIsTrivialAlias(Dsymbol s)
303-
{
304-
/* Set isTrivialAliasSeq if this fits the pattern:
305-
* template AliasSeq(T...) { alias AliasSeq = T; }
306-
* or set isTrivialAlias if this fits the pattern:
307-
* template Alias(T) { alias Alias = qualifiers(T); }
308-
*/
309-
if (!(parameters && parameters.length == 1))
310-
return;
311-
312-
auto ad = s.isAliasDeclaration();
313-
if (!ad || !ad.type)
314-
return;
315-
316-
auto ti = ad.type.isTypeIdentifier();
317-
318-
if (!ti || ti.idents.length != 0)
319-
return;
320-
321-
if (auto ttp = (*parameters)[0].isTemplateTupleParameter())
322-
{
323-
if (ti.ident is ttp.ident &&
324-
ti.mod == 0)
325-
{
326-
//printf("found isTrivialAliasSeq %s %s\n", s.toChars(), ad.type.toChars());
327-
isTrivialAliasSeq = true;
328-
}
329-
}
330-
else if (auto ttp = (*parameters)[0].isTemplateTypeParameter())
331-
{
332-
if (ti.ident is ttp.ident)
333-
{
334-
//printf("found isTrivialAlias %s %s\n", s.toChars(), ad.type.toChars());
335-
isTrivialAlias = true;
336-
}
337-
}
338-
}
339-
340302
override TemplateDeclaration syntaxCopy(Dsymbol)
341303
{
342304
//printf("TemplateDeclaration.syntaxCopy()\n");

compiler/src/dmd/templatesem.d

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,44 @@ void computeOneMember(TemplateDeclaration td)
455455
}
456456
}
457457

458+
private void computeIsTrivialAlias(TemplateDeclaration td, Dsymbol s)
459+
{
460+
/* Set isTrivialAliasSeq if this fits the pattern:
461+
* template AliasSeq(T...) { alias AliasSeq = T; }
462+
* or set isTrivialAlias if this fits the pattern:
463+
* template Alias(T) { alias Alias = qualifiers(T); }
464+
*/
465+
if (!(td.parameters && td.parameters.length == 1))
466+
return;
467+
468+
auto ad = s.isAliasDeclaration();
469+
if (!ad || !ad.type)
470+
return;
471+
472+
auto ti = ad.type.isTypeIdentifier();
473+
474+
if (!ti || ti.idents.length != 0)
475+
return;
476+
477+
if (auto ttp = (*td.parameters)[0].isTemplateTupleParameter())
478+
{
479+
if (ti.ident is ttp.ident &&
480+
ti.mod == 0)
481+
{
482+
//printf("found isTrivialAliasSeq %s %s\n", s.toChars(), ad.type.toChars());
483+
td.isTrivialAliasSeq = true;
484+
}
485+
}
486+
else if (auto ttp = (*td.parameters)[0].isTemplateTypeParameter())
487+
{
488+
if (ti.ident is ttp.ident)
489+
{
490+
//printf("found isTrivialAlias %s %s\n", s.toChars(), ad.type.toChars());
491+
td.isTrivialAlias = true;
492+
}
493+
}
494+
}
495+
458496
bool declareParameter(TemplateParameter _this, Scope* sc)
459497
{
460498
static bool typeDeclareParameter(TemplateTypeParameter _this, Scope* sc)

0 commit comments

Comments
 (0)