"math/rand"
"os"
. "reflect"
+ "reflect/internal/example1"
+ "reflect/internal/example2"
"runtime"
"sort"
"strconv"
type MyStruct struct {
x int `some:"tag"`
}
+type MyStruct1 struct {
+ x struct {
+ int `some:"bar"`
+ }
+}
+type MyStruct2 struct {
+ x struct {
+ int `some:"foo"`
+ }
+}
type MyString string
type MyBytes []byte
type MyRunes []int32
x int `some:"bar"`
}{}), V(MyStruct{})},
+ {V(MyStruct1{}), V(MyStruct2{})},
+ {V(MyStruct2{}), V(MyStruct1{})},
+
// can convert *byte and *MyByte
{V((*byte)(nil)), V((*MyByte)(nil))},
{V((*MyByte)(nil)), V((*byte)(nil))},
sort.Strings(got)
return "[" + strings.Join(got, ", ") + "]"
}
+
+func TestConvertibleTo(t *testing.T) {
+ t1 := ValueOf(example1.MyStruct{}).Type()
+ t2 := ValueOf(example2.MyStruct{}).Type()
+
+ // Shouldn't raise stack overflow
+ if t1.ConvertibleTo(t2) {
+ t.Fatalf("(%s).ConvertibleTo(%s) = true, want false", t1, t2)
+ }
+}