Skip to content

Commit

Permalink
go/types, types2: remove need for Scope.LookupParent from TestObjectS…
Browse files Browse the repository at this point in the history
…tring

Updates #69673.

Change-Id: I0ce5f009c1e95a2722a50d79a74fef83d2547b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/616260
Auto-Submit: Robert Griesemer <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
griesemer authored and gopherbot committed Sep 27, 2024
1 parent 8031651 commit 99bf122
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cmd/compile/internal/types2/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,15 @@ func TestObjectString(t *testing.T) {
if len(names) != 1 && len(names) != 2 {
t.Fatalf("%s: invalid object path %s", test.src, test.obj)
}
_, obj := pkg.Scope().LookupParent(names[0], nopos)

var obj Object
for s := pkg.Scope(); s != nil && obj == nil; s = s.Parent() {
obj = s.Lookup(names[0])
}
if obj == nil {
t.Fatalf("%s: %s not found", test.src, names[0])
}

if len(names) == 2 {
if typ, ok := obj.Type().(interface{ TypeParams() *TypeParamList }); ok {
obj = lookupTypeParamObj(typ.TypeParams(), names[1])
Expand Down
7 changes: 6 additions & 1 deletion src/go/types/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ func TestObjectString(t *testing.T) {
if len(names) != 1 && len(names) != 2 {
t.Fatalf("%s: invalid object path %s", test.src, test.obj)
}
_, obj := pkg.Scope().LookupParent(names[0], nopos)

var obj Object
for s := pkg.Scope(); s != nil && obj == nil; s = s.Parent() {
obj = s.Lookup(names[0])
}
if obj == nil {
t.Fatalf("%s: %s not found", test.src, names[0])
}

if len(names) == 2 {
if typ, ok := obj.Type().(interface{ TypeParams() *TypeParamList }); ok {
obj = lookupTypeParamObj(typ.TypeParams(), names[1])
Expand Down

0 comments on commit 99bf122

Please sign in to comment.