From 99bf122de86ffec5ebd85a688432619d717025fe Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 27 Sep 2024 10:41:55 -0700 Subject: [PATCH] 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 Reviewed-by: Robert Griesemer Reviewed-by: Alan Donovan LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/types2/object_test.go | 7 ++++++- src/go/types/object_test.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/types2/object_test.go b/src/cmd/compile/internal/types2/object_test.go index 955fa351a467d..f19264e4db6d4 100644 --- a/src/cmd/compile/internal/types2/object_test.go +++ b/src/cmd/compile/internal/types2/object_test.go @@ -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]) diff --git a/src/go/types/object_test.go b/src/go/types/object_test.go index 704d4128ba86b..0b4fce7bb161c 100644 --- a/src/go/types/object_test.go +++ b/src/go/types/object_test.go @@ -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])