]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: fix method type string
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 13 May 2016 16:33:27 +0000 (12:33 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 13 May 2016 17:44:48 +0000 (17:44 +0000)
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>

src/reflect/all_test.go
src/reflect/type.go

index 5beec63273b52695ff164efec8cb2e4c86aac184..9799fee35735576cc04532a312546db54e92cbec 100644 (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)
+               }
+       }
+}
index 5c6e3d55009d7ece6e7cfd7fcf70eb5eef38afb8..3bfff4a7cc6aa0ea8c391bdf0f17f613b576a481 100644 (file)
@@ -1985,6 +1985,7 @@ func FuncOf(in, out []Type, variadic bool) Type {
        if len(args) > 50 {
                panic("reflect.FuncOf does not support more than 50 arguments")
        }
+       ft.tflag = 0
        ft.hash = hash
        ft.inCount = uint16(len(in))
        ft.outCount = uint16(len(out))