mirror of
https://github.com/golang/go
synced 2024-11-16 16:54:39 -07:00
reflect: clear tflag on new types
Fixes #16722 Change-Id: I50a0e69d3e79d13bc1860cd983267c3db087a4b8 Reviewed-on: https://go-review.googlesource.com/27119 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
d251030fa6
commit
56752eb2b8
@ -5720,6 +5720,8 @@ func TestTypeStrings(t *testing.T) {
|
|||||||
{TypeOf(new(XM)), "*reflect_test.XM"},
|
{TypeOf(new(XM)), "*reflect_test.XM"},
|
||||||
{TypeOf(new(XM).String), "func() string"},
|
{TypeOf(new(XM).String), "func() string"},
|
||||||
{TypeOf(new(XM)).Method(0).Type, "func(*reflect_test.XM) string"},
|
{TypeOf(new(XM)).Method(0).Type, "func(*reflect_test.XM) string"},
|
||||||
|
{ChanOf(3, TypeOf(XM{})), "chan reflect_test.XM"},
|
||||||
|
{MapOf(TypeOf(int(0)), TypeOf(XM{})), "map[int]reflect_test.XM"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range stringTests {
|
for i, test := range stringTests {
|
||||||
|
@ -1848,6 +1848,7 @@ func ChanOf(dir ChanDir, t Type) Type {
|
|||||||
prototype := *(**chanType)(unsafe.Pointer(&ichan))
|
prototype := *(**chanType)(unsafe.Pointer(&ichan))
|
||||||
ch := new(chanType)
|
ch := new(chanType)
|
||||||
*ch = *prototype
|
*ch = *prototype
|
||||||
|
ch.tflag = 0
|
||||||
ch.dir = uintptr(dir)
|
ch.dir = uintptr(dir)
|
||||||
ch.str = resolveReflectName(newName(s, "", "", false))
|
ch.str = resolveReflectName(newName(s, "", "", false))
|
||||||
ch.hash = fnv1(typ.hash, 'c', byte(dir))
|
ch.hash = fnv1(typ.hash, 'c', byte(dir))
|
||||||
@ -1892,6 +1893,7 @@ func MapOf(key, elem Type) Type {
|
|||||||
mt := new(mapType)
|
mt := new(mapType)
|
||||||
*mt = **(**mapType)(unsafe.Pointer(&imap))
|
*mt = **(**mapType)(unsafe.Pointer(&imap))
|
||||||
mt.str = resolveReflectName(newName(s, "", "", false))
|
mt.str = resolveReflectName(newName(s, "", "", false))
|
||||||
|
mt.tflag = 0
|
||||||
mt.hash = fnv1(etyp.hash, 'm', byte(ktyp.hash>>24), byte(ktyp.hash>>16), byte(ktyp.hash>>8), byte(ktyp.hash))
|
mt.hash = fnv1(etyp.hash, 'm', byte(ktyp.hash>>24), byte(ktyp.hash>>16), byte(ktyp.hash>>8), byte(ktyp.hash))
|
||||||
mt.key = ktyp
|
mt.key = ktyp
|
||||||
mt.elem = etyp
|
mt.elem = etyp
|
||||||
|
Loading…
Reference in New Issue
Block a user