@@ -61,9 +61,6 @@ func (p *noder) decls(decls []syntax.Decl) (l []*Node) {
61
61
case * syntax.ImportDecl :
62
62
p .importDecl (decl )
63
63
64
- case * syntax.AliasDecl :
65
- p .aliasDecl (decl )
66
-
67
64
case * syntax.VarDecl :
68
65
l = append (l , p .varDecl (decl )... )
69
66
@@ -150,100 +147,6 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) {
150
147
my .Block = 1 // at top level
151
148
}
152
149
153
- func (p * noder ) aliasDecl (decl * syntax.AliasDecl ) {
154
- // Because alias declarations must refer to imported entities
155
- // which are already set up, we can do all checks right here.
156
- // We won't know anything about entities that have not been
157
- // declared yet, but since they cannot have been imported, we
158
- // know there's an error and we don't care about the details.
159
-
160
- // The original entity must be denoted by a qualified identifier.
161
- // (The parser doesn't make this restriction to be more error-
162
- // tolerant.)
163
- qident , ok := decl .Orig .(* syntax.SelectorExpr )
164
- if ! ok {
165
- // TODO(gri) This prints a dot-imported object with qualification
166
- // (confusing error). Fix this.
167
- yyerror ("invalid alias: %v is not a package-qualified identifier" , p .expr (decl .Orig ))
168
- return
169
- }
170
-
171
- pkg := p .expr (qident .X )
172
- if pkg .Op != OPACK {
173
- yyerror ("invalid alias: %v is not a package" , pkg )
174
- return
175
- }
176
- pkg .Used = true
177
-
178
- // Resolve original entity
179
- orig := oldname (restrictlookup (qident .Sel .Value , pkg .Name .Pkg ))
180
- if orig .Sym .Flags & SymAlias != 0 {
181
- Fatalf ("original %v marked as alias" , orig .Sym )
182
- }
183
-
184
- // An alias declaration must not refer to package unsafe.
185
- if orig .Sym .Pkg == unsafepkg {
186
- yyerror ("invalid alias: %v refers to package unsafe (%v)" , decl .Name .Value , orig )
187
- return
188
- }
189
-
190
- // The aliased entity must be from a matching constant, type, variable,
191
- // or function declaration, respectively.
192
- var what string
193
- switch decl .Tok {
194
- case syntax .Const :
195
- if orig .Op != OLITERAL {
196
- what = "constant"
197
- }
198
- case syntax .Type :
199
- if orig .Op != OTYPE {
200
- what = "type"
201
- }
202
- case syntax .Var :
203
- if orig .Op != ONAME || orig .Class != PEXTERN {
204
- what = "variable"
205
- }
206
- case syntax .Func :
207
- if orig .Op != ONAME || orig .Class != PFUNC {
208
- what = "function"
209
- }
210
- default :
211
- Fatalf ("unexpected token: %s" , decl .Tok )
212
- }
213
- if what != "" {
214
- yyerror ("invalid alias: %v is not a %s" , orig , what )
215
- return
216
- }
217
-
218
- // handle special cases
219
- switch decl .Name .Value {
220
- case "_" :
221
- return // don't declare blank aliases
222
- case "init" :
223
- yyerror ("cannot declare init - must be non-alias function declaration" )
224
- return
225
- }
226
-
227
- // declare alias
228
- // (this is similar to handling dot imports)
229
- asym := p .name (decl .Name )
230
- if asym .Def != nil {
231
- redeclare (asym , "in alias declaration" )
232
- return
233
- }
234
- asym .Flags |= SymAlias
235
- asym .Def = orig
236
- asym .Block = block
237
- asym .Lastlineno = lineno
238
-
239
- if exportname (asym .Name ) {
240
- // TODO(gri) newname(asym) is only needed to satisfy exportsym
241
- // (and indirectly, exportlist). We should be able to just
242
- // collect the Syms, eventually.
243
- exportsym (newname (asym ))
244
- }
245
- }
246
-
247
150
func (p * noder ) varDecl (decl * syntax.VarDecl ) []* Node {
248
151
names := p .declNames (decl .NameList )
249
152
0 commit comments