diff --git a/compiler/src/dmd/astbase.d b/compiler/src/dmd/astbase.d index ae57aaf702e4..31b8bdf64f2c 100644 --- a/compiler/src/dmd/astbase.d +++ b/compiler/src/dmd/astbase.d @@ -390,16 +390,6 @@ struct ASTBase this.ident = id; } } - void addAlias(Identifier name, Identifier _alias) - { - if (isstatic) - error(loc, "cannot have an import bind list"); - if (!aliasId) - this.ident = null; - - names.push(name); - aliases.push(_alias); - } override void accept(Visitor v) { diff --git a/compiler/src/dmd/dimport.d b/compiler/src/dmd/dimport.d index 4c4c063cbf27..96e821aea6af 100644 --- a/compiler/src/dmd/dimport.d +++ b/compiler/src/dmd/dimport.d @@ -14,7 +14,6 @@ module dmd.dimport; import dmd.arraytypes; import dmd.dmodule; import dmd.dsymbol; -import dmd.errors; import dmd.identifier; import dmd.location; import dmd.visitor; @@ -84,16 +83,6 @@ extern (C++) final class Import : Dsymbol this.visibility = Visibility.Kind.private_; // default to private } - extern (D) void addAlias(Identifier name, Identifier _alias) - { - if (isstatic) - .error(loc, "%s `%s` cannot have an import bind list", kind, toPrettyChars); - if (!aliasId) - this.ident = null; // make it an anonymous import - names.push(name); - aliases.push(_alias); - } - override const(char)* kind() const { return isstatic ? "static import" : "import"; @@ -110,9 +99,13 @@ extern (C++) final class Import : Dsymbol assert(!s); auto si = new Import(loc, packages, id, aliasId, isstatic); si.comment = comment; + assert(!(isstatic && names.length)); + if (names.length && !si.aliasId) + si.ident = null; for (size_t i = 0; i < names.length; i++) { - si.addAlias(names[i], aliases[i]); + si.names.push(names[i]); + si.aliases.push(aliases[i]); } return si; } diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index 33eab2ed709b..4fbc3725a7dd 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -3501,7 +3501,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer name = _alias; _alias = null; } - s.addAlias(name, _alias); + if (s.isstatic) + error(loc, "static import `%s` cannot have an import bind list", s.toPrettyChars()); + if (!s.aliasId) + s.ident = null; // make it an anonymous import + s.names.push(name); + s.aliases.push(_alias); } while (token.value == TOK.comma); break; // no comma-separated imports of this form