diff options
Diffstat (limited to 'src/pkg/go/ast/ast.go')
-rw-r--r-- | src/pkg/go/ast/ast.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/go/ast/ast.go b/src/pkg/go/ast/ast.go index 4b90f3b74..efe2af459 100644 --- a/src/pkg/go/ast/ast.go +++ b/src/pkg/go/ast/ast.go @@ -596,6 +596,7 @@ func (s *RangeStmt) stmtNode() {} type ( // The Spec type stands for any of *ImportSpec, *ValueSpec, and *TypeSpec. Spec interface { + Node; specNode(); }; @@ -627,6 +628,23 @@ type ( ) +// Pos() implementations for spec nodes. +// +func (s *ImportSpec) Pos() token.Position { + if s.Name != nil { + return s.Name.Pos(); + } + return s.Path[0].Pos(); +} + +func (s *ValueSpec) Pos() token.Position { + return s.Names[0].Pos(); +} +func (s *TypeSpec) Pos() token.Position { + return s.Name.Pos(); +} + + // specNode() ensures that only spec nodes can be // assigned to a Spec. // |