diff --git a/src/cmd/compile/internal/types2/object_test.go b/src/cmd/compile/internal/types2/object_test.go index 955fa351a4..f19264e4db 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 704d4128ba..0b4fce7bb1 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])