Fixes #8427.
Change-Id: I826a3bc4519845ad30d6dbaf058fe7ed7bee8db0
Reviewed-on: https://go-review.googlesource.com/12233
Reviewed-by: Ian Lance Taylor <iant@golang.org>
}
var sptr *Sym
- if t.Sym != nil && !Isptr[t.Etype] {
- sptr = dtypesym(Ptrto(t))
+ tptr := Ptrto(t)
+ if !Isptr[t.Etype] && (t.Sym != nil || methods(tptr) != nil) {
+ sptr = dtypesym(tptr)
} else {
- sptr = weaktypesym(Ptrto(t))
+ sptr = weaktypesym(tptr)
}
// All (non-reflect-allocated) Types share the same zero object.
check("PtrTo", PtrTo(TypeOf(T{})))
check("SliceOf", SliceOf(TypeOf(T{})))
}
+
+type XM struct{}
+
+func (*XM) String() string { return "" }
+
+func TestPtrToMethods(t *testing.T) {
+ var y struct{ XM }
+ yp := New(TypeOf(y)).Interface()
+ _, ok := yp.(fmt.Stringer)
+ if !ok {
+ t.Fatal("does not implement Stringer, but should")
+ }
+}