mirror of
https://github.com/golang/go
synced 2024-11-15 01:50:28 -07:00
go/types, types2: replace 2 uses of Scope.LookupParent with Checker.lookup
A step towards removing reliance on Scope.LookupParent. Updates #69673. Change-Id: I9fdd4b08ea600b531b90895ac779fdc580ff00e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/616259 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Griesemer <gri@google.com> Commit-Queue: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
5fe3b31cf8
commit
de46eaadb5
@ -701,7 +701,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *TypeName
|
|||||||
for _, prefix := range cgoPrefixes {
|
for _, prefix := range cgoPrefixes {
|
||||||
// cgo objects are part of the current package (in file
|
// cgo objects are part of the current package (in file
|
||||||
// _cgo_gotypes.go). Use regular lookup.
|
// _cgo_gotypes.go). Use regular lookup.
|
||||||
_, exp = check.scope.LookupParent(prefix+sel, check.pos)
|
exp = check.lookup(prefix + sel)
|
||||||
if exp != nil {
|
if exp != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -963,7 +963,7 @@ func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
|
|||||||
var v *Var
|
var v *Var
|
||||||
var v_used bool
|
var v_used bool
|
||||||
if lhs {
|
if lhs {
|
||||||
if _, obj := check.scope.LookupParent(n.Value, nopos); obj != nil {
|
if obj := check.lookup(n.Value); obj != nil {
|
||||||
// It's ok to mark non-local variables, but ignore variables
|
// It's ok to mark non-local variables, but ignore variables
|
||||||
// from other packages to avoid potential race conditions with
|
// from other packages to avoid potential race conditions with
|
||||||
// dot-imported variables.
|
// dot-imported variables.
|
||||||
|
@ -704,7 +704,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, def *TypeName, w
|
|||||||
for _, prefix := range cgoPrefixes {
|
for _, prefix := range cgoPrefixes {
|
||||||
// cgo objects are part of the current package (in file
|
// cgo objects are part of the current package (in file
|
||||||
// _cgo_gotypes.go). Use regular lookup.
|
// _cgo_gotypes.go). Use regular lookup.
|
||||||
_, exp = check.scope.LookupParent(prefix+sel, check.pos)
|
exp = check.lookup(prefix + sel)
|
||||||
if exp != nil {
|
if exp != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1012,7 +1012,7 @@ func (check *Checker) use1(e ast.Expr, lhs bool) bool {
|
|||||||
var v *Var
|
var v *Var
|
||||||
var v_used bool
|
var v_used bool
|
||||||
if lhs {
|
if lhs {
|
||||||
if _, obj := check.scope.LookupParent(n.Name, nopos); obj != nil {
|
if obj := check.lookup(n.Name); obj != nil {
|
||||||
// It's ok to mark non-local variables, but ignore variables
|
// It's ok to mark non-local variables, but ignore variables
|
||||||
// from other packages to avoid potential race conditions with
|
// from other packages to avoid potential race conditions with
|
||||||
// dot-imported variables.
|
// dot-imported variables.
|
||||||
|
Loading…
Reference in New Issue
Block a user