@@ -22,7 +22,7 @@ import dmd.delegatize;
2222import dmd.dscope;
2323import dmd.dstruct;
2424import dmd.dsymbol;
25- import dmd.dsymbolsem : dsymbolSemantic, aliasSemantic ;
25+ import dmd.dsymbolsem : toAlias ;
2626import dmd.dtemplate;
2727import dmd.errors;
2828import dmd.expression;
@@ -40,7 +40,7 @@ import dmd.rootobject;
4040import dmd.root.filename;
4141import dmd.target;
4242import dmd.tokens;
43- import dmd.typesem : toDsymbol, typeSemantic, size;
43+ import dmd.typesem : typeSemantic, size;
4444import dmd.visitor;
4545
4646version (IN_GCC) {}
@@ -356,21 +356,6 @@ extern (C++) final class TupleDeclaration : Declaration
356356 return tupletype;
357357 }
358358
359- override Dsymbol toAlias2 ()
360- {
361- // printf("TupleDeclaration::toAlias2() '%s' objects = %s\n", toChars(), objects.toChars());
362- for (size_t i = 0 ; i < objects.length; i++ )
363- {
364- RootObject o = (* objects)[i];
365- if (Dsymbol s = isDsymbol(o))
366- {
367- s = s.toAlias2();
368- (* objects)[i] = s;
369- }
370- }
371- return this ;
372- }
373-
374359 override bool needThis ()
375360 {
376361 // printf("TupleDeclaration::needThis(%s)\n", toChars());
@@ -599,117 +584,7 @@ extern (C++) final class AliasDeclaration : Declaration
599584 {
600585 if (type)
601586 return type;
602- return toAlias ().getType();
603- }
604-
605- override Dsymbol toAlias ()
606- {
607- static if (0 )
608- printf(" [%s] AliasDeclaration::toAlias('%s', this = %p, aliassym: %s, kind: '%s', inuse = %d)\n " ,
609- loc.toChars(), toChars (), this , aliassym ? aliassym.toChars() : " " , aliassym ? aliassym.kind() : " " , inuse);
610- assert (this != aliassym);
611- // static int count; if (++count == 10) *(char*)0=0;
612-
613- Dsymbol err ()
614- {
615- // Avoid breaking "recursive alias" state during errors gagged
616- if (global.gag)
617- return this ;
618- aliassym = new AliasDeclaration(loc, ident, Type.terror);
619- type = Type.terror;
620- return aliassym;
621- }
622- // Reading the AliasDeclaration
623- if (! this .ignoreRead)
624- this .wasRead = true ; // can never assign to this AliasDeclaration again
625-
626- if (inuse == 1 && type && _scope)
627- {
628- inuse = 2 ;
629- const olderrors = global.errors;
630- Dsymbol s = type.toDsymbol(_scope);
631- // printf("[%s] type = %s, s = %p, this = %p\n", loc.toChars(), type.toChars(), s, this);
632- if (global.errors != olderrors)
633- return err ();
634- if (s)
635- {
636- s = s.toAlias();
637- if (global.errors != olderrors)
638- return err ();
639- aliassym = s;
640- inuse = 0 ;
641- }
642- else
643- {
644- Type t = type.typeSemantic(loc, _scope);
645- if (t.ty == Terror)
646- return err ();
647- if (global.errors != olderrors)
648- return err ();
649- // printf("t = %s\n", t.toChars());
650- inuse = 0 ;
651- }
652- }
653- if (inuse)
654- {
655- .error(loc, " %s `%s` recursive alias declaration" , kind, toPrettyChars);
656- return err ();
657- }
658-
659- if (semanticRun >= PASS .semanticdone)
660- {
661- // semantic is already done.
662-
663- // Do not see aliassym !is null, because of lambda aliases.
664-
665- // Do not see type.deco !is null, even so "alias T = const int;` needs
666- // semantic analysis to take the storage class `const` as type qualifier.
667- }
668- else
669- {
670- // stop AliasAssign tuple building
671- if (aliassym)
672- {
673- if (auto td = aliassym.isTupleDeclaration())
674- {
675- if (td.building)
676- {
677- td.building = false ;
678- semanticRun = PASS .semanticdone;
679- return td;
680- }
681- }
682- }
683- if (_import && _import._scope)
684- {
685- /* If this is an internal alias for selective/renamed import,
686- * load the module first.
687- */
688- _import.dsymbolSemantic(null );
689- }
690- if (_scope)
691- {
692- aliasSemantic(this , _scope);
693- }
694- }
695-
696- inuse = 1 ;
697- Dsymbol s = aliassym ? aliassym.toAlias() : this ;
698- inuse = 0 ;
699- return s;
700- }
701-
702- override Dsymbol toAlias2 ()
703- {
704- if (inuse)
705- {
706- .error(loc, " %s `%s` recursive alias declaration" , kind, toPrettyChars);
707- return this ;
708- }
709- inuse = 1 ;
710- Dsymbol s = aliassym ? aliassym.toAlias2() : this ;
711- inuse = 0 ;
712- return s;
587+ return toAlias (this ).getType();
713588 }
714589
715590 override bool isOverloadable () const
@@ -1049,17 +924,6 @@ extern (C++) class VarDeclaration : Declaration
1049924 return edtor && ! (storage_class & STC .nodtor);
1050925 }
1051926
1052- override final Dsymbol toAlias ()
1053- {
1054- // printf("VarDeclaration::toAlias('%s', this = %p, aliassym = %p)\n", toChars(), this, aliassym);
1055- if ((! type || ! type.deco) && _scope)
1056- dsymbolSemantic(this , _scope);
1057-
1058- assert (this != aliasTuple);
1059- Dsymbol s = aliasTuple ? aliasTuple.toAlias() : this ;
1060- return s;
1061- }
1062-
1063927 override void accept (Visitor v)
1064928 {
1065929 v.visit(this );
0 commit comments