]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: replace 2 uses of Scope.LookupParent with Checker.lookup
authorRobert Griesemer <gri@golang.org>
Fri, 27 Sep 2024 16:42:41 +0000 (09:42 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 27 Sep 2024 17:31:05 +0000 (17:31 +0000)
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>
src/cmd/compile/internal/types2/call.go
src/go/types/call.go

index ea4b174f657ddbd0020bed78ae69f73655b0ba0b..4ff5fe49e76bae777269198bce5d9a2405de9f16 100644 (file)
@@ -701,7 +701,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *TypeName
                                for _, prefix := range cgoPrefixes {
                                        // cgo objects are part of the current package (in file
                                        // _cgo_gotypes.go). Use regular lookup.
-                                       _, exp = check.scope.LookupParent(prefix+sel, check.pos)
+                                       exp = check.lookup(prefix + sel)
                                        if exp != nil {
                                                break
                                        }
@@ -963,7 +963,7 @@ func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
                var v *Var
                var v_used bool
                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
                                // from other packages to avoid potential race conditions with
                                // dot-imported variables.
index f14b408829248b1d28684f289ebe7e2d79f4dced..e4d0d927f5f36fdcaabf6f7138c0594af8ca41bc 100644 (file)
@@ -704,7 +704,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, def *TypeName, w
                                for _, prefix := range cgoPrefixes {
                                        // cgo objects are part of the current package (in file
                                        // _cgo_gotypes.go). Use regular lookup.
-                                       _, exp = check.scope.LookupParent(prefix+sel, check.pos)
+                                       exp = check.lookup(prefix + sel)
                                        if exp != nil {
                                                break
                                        }
@@ -1012,7 +1012,7 @@ func (check *Checker) use1(e ast.Expr, lhs bool) bool {
                var v *Var
                var v_used bool
                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
                                // from other packages to avoid potential race conditions with
                                // dot-imported variables.