1
0
mirror of https://github.com/golang/go synced 2024-11-14 22:40:40 -07:00

go/types, types2: remove need for Scope.LookupParent from TestObjectString

Updates #69673.

Change-Id: I0ce5f009c1e95a2722a50d79a74fef83d2547b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/616260
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Robert Griesemer 2024-09-27 10:41:55 -07:00 committed by Gopher Robot
parent 80316510d3
commit 99bf122de8
2 changed files with 12 additions and 2 deletions

View File

@ -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])

View File

@ -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])