reflect: fix method type string

By picking up a spurious tFlagExtraStar, the method type was printing
as unc instead of func.

Updates #15673

Change-Id: I0c2c189b99bdd4caeb393693be7520b8e3f342bf
Reviewed-on: https://go-review.googlesource.com/23103
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
David Crawshaw 2016-05-13 12:33:27 -04:00
parent 2cc0f22096
commit 0cc710dca6
2 changed files with 22 additions and 0 deletions

View file

@ -5782,3 +5782,24 @@ func TestMethodPkgPathReadable(t *testing.T) {
t.Errorf(`PkgPath=%q, want "reflect"`, m.PkgPath)
}
}
func TestTypeStrings(t *testing.T) {
type stringTest struct {
typ Type
want string
}
stringTests := []stringTest{
{TypeOf(func(int) {}), "func(int)"},
{FuncOf([]Type{TypeOf(int(0))}, nil, false), "func(int)"},
{TypeOf(XM{}), "reflect_test.XM"},
{TypeOf(new(XM)), "*reflect_test.XM"},
{TypeOf(new(XM).String), "func() string"},
{TypeOf(new(XM)).Method(0).Type, "func(*reflect_test.XM) string"},
}
for i, test := range stringTests {
if got, want := test.typ.String(), test.want; got != want {
t.Errorf("type %d String()=%q, want %q", i, got, want)
}
}
}