diff options
author | Robert Griesemer <gri@golang.org> | 2021-04-05 15:48:32 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-04-07 05:19:29 +0000 |
commit | 8f1099b5850747cf61738606f6a3d1386f4458c6 (patch) | |
tree | 15929d236805b05affbb0829e401d3e3bbcb0354 /src/cmd/compile/internal/types2/scope.go | |
parent | 1395432f2330498c8e5661c14652996894f0cc7d (diff) | |
download | go-8f1099b5850747cf61738606f6a3d1386f4458c6.tar.gz go-8f1099b5850747cf61738606f6a3d1386f4458c6.zip |
cmd/compile/internal/syntax, types2: move cmpPos to pos.Cmp
Make position comparison generally available.
Change-Id: I94b6f658fa19a15b30574dbb2181879115c131a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/307215
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/scope.go')
-rw-r--r-- | src/cmd/compile/internal/types2/scope.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/types2/scope.go b/src/cmd/compile/internal/types2/scope.go index fd0b6241f5..ade0a79b31 100644 --- a/src/cmd/compile/internal/types2/scope.go +++ b/src/cmd/compile/internal/types2/scope.go @@ -81,7 +81,7 @@ func (s *Scope) Lookup(name string) Object { // whose scope is the scope of the package that exported them. func (s *Scope) LookupParent(name string, pos syntax.Pos) (*Scope, Object) { for ; s != nil; s = s.parent { - if obj := s.elems[name]; obj != nil && (!pos.IsKnown() || cmpPos(obj.scopePos(), pos) <= 0) { + if obj := s.elems[name]; obj != nil && (!pos.IsKnown() || obj.scopePos().Cmp(pos) <= 0) { return s, obj } } @@ -153,7 +153,7 @@ func (s *Scope) End() syntax.Pos { return s.end } // The result is guaranteed to be valid only if the type-checked // AST has complete position information. func (s *Scope) Contains(pos syntax.Pos) bool { - return cmpPos(s.pos, pos) <= 0 && cmpPos(pos, s.end) < 0 + return s.pos.Cmp(pos) <= 0 && pos.Cmp(s.end) < 0 } // Innermost returns the innermost (child) scope containing |