From 378f73e2d56998fba872decd61583d96cd9b1f77 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 19 Feb 2021 16:47:04 -0800 Subject: [PATCH] cmd/compile/internal/types2: enable TestIssue25627 Since we have syntax.Walk, we can make this test work again. Change-Id: I55cbde7303e5bcbe1123b6679f2ce859d377fd86 Reviewed-on: https://go-review.googlesource.com/c/go/+/294472 Trust: Robert Griesemer Reviewed-by: Robert Findley --- .../compile/internal/types2/issues_test.go | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/cmd/compile/internal/types2/issues_test.go b/src/cmd/compile/internal/types2/issues_test.go index 5a32fa590ac..ba7cefb8925 100644 --- a/src/cmd/compile/internal/types2/issues_test.go +++ b/src/cmd/compile/internal/types2/issues_test.go @@ -300,8 +300,6 @@ func TestIssue22525(t *testing.T) { } func TestIssue25627(t *testing.T) { - t.Skip("requires syntax tree inspection") - const prefix = `package p; import "unsafe"; type P *struct{}; type I interface{}; type T ` // The src strings (without prefix) are constructed such that the number of semicolons // plus one corresponds to the number of fields expected in the respective struct. @@ -325,20 +323,17 @@ func TestIssue25627(t *testing.T) { } } - unimplemented() - /* - ast.Inspect(f, func(n syntax.Node) bool { - if spec, _ := n.(*syntax.TypeDecl); spec != nil { - if tv, ok := info.Types[spec.Type]; ok && spec.Name.Value == "T" { - want := strings.Count(src, ";") + 1 - if got := tv.Type.(*Struct).NumFields(); got != want { - t.Errorf("%s: got %d fields; want %d", src, got, want) - } + syntax.Walk(f, func(n syntax.Node) bool { + if decl, _ := n.(*syntax.TypeDecl); decl != nil { + if tv, ok := info.Types[decl.Type]; ok && decl.Name.Value == "T" { + want := strings.Count(src, ";") + 1 + if got := tv.Type.(*Struct).NumFields(); got != want { + t.Errorf("%s: got %d fields; want %d", src, got, want) } } - return true - }) - */ + } + return false + }) } }