|
1 From 9b4e323e883353e870879fe87c2c16872f43a98d Mon Sep 17 00:00:00 2001 |
|
2 From: David Crawshaw <[email protected]> |
|
3 Date: Tue, 16 Aug 2016 07:44:57 -0400 |
|
4 Subject: [PATCH 06/38] [release-branch.go1.7] reflect: clear tflag on new |
|
5 types |
|
6 |
|
7 Fixes #16722 |
|
8 |
|
9 Change-Id: I50a0e69d3e79d13bc1860cd983267c3db087a4b8 |
|
10 Reviewed-on: https://go-review.googlesource.com/27119 |
|
11 Reviewed-by: Brad Fitzpatrick <[email protected]> |
|
12 Run-TryBot: Brad Fitzpatrick <[email protected]> |
|
13 TryBot-Result: Gobot Gobot <[email protected]> |
|
14 Reviewed-on: https://go-review.googlesource.com/28630 |
|
15 --- |
|
16 src/reflect/all_test.go | 2 ++ |
|
17 src/reflect/type.go | 2 ++ |
|
18 2 files changed, 4 insertions(+) |
|
19 |
|
20 diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go |
|
21 index bbb098f..780799c 100644 |
|
22 --- a/src/reflect/all_test.go |
|
23 +++ b/src/reflect/all_test.go |
|
24 @@ -5720,6 +5720,8 @@ func TestTypeStrings(t *testing.T) { |
|
25 {TypeOf(new(XM)), "*reflect_test.XM"}, |
|
26 {TypeOf(new(XM).String), "func() string"}, |
|
27 {TypeOf(new(XM)).Method(0).Type, "func(*reflect_test.XM) string"}, |
|
28 + {ChanOf(3, TypeOf(XM{})), "chan reflect_test.XM"}, |
|
29 + {MapOf(TypeOf(int(0)), TypeOf(XM{})), "map[int]reflect_test.XM"}, |
|
30 } |
|
31 |
|
32 for i, test := range stringTests { |
|
33 diff --git a/src/reflect/type.go b/src/reflect/type.go |
|
34 index de6e05f..8916710 100644 |
|
35 --- a/src/reflect/type.go |
|
36 +++ b/src/reflect/type.go |
|
37 @@ -1848,6 +1848,7 @@ func ChanOf(dir ChanDir, t Type) Type { |
|
38 prototype := *(**chanType)(unsafe.Pointer(&ichan)) |
|
39 ch := new(chanType) |
|
40 *ch = *prototype |
|
41 + ch.tflag = 0 |
|
42 ch.dir = uintptr(dir) |
|
43 ch.str = resolveReflectName(newName(s, "", "", false)) |
|
44 ch.hash = fnv1(typ.hash, 'c', byte(dir)) |
|
45 @@ -1892,6 +1893,7 @@ func MapOf(key, elem Type) Type { |
|
46 mt := new(mapType) |
|
47 *mt = **(**mapType)(unsafe.Pointer(&imap)) |
|
48 mt.str = resolveReflectName(newName(s, "", "", false)) |
|
49 + mt.tflag = 0 |
|
50 mt.hash = fnv1(etyp.hash, 'm', byte(ktyp.hash>>24), byte(ktyp.hash>>16), byte(ktyp.hash>>8), byte(ktyp.hash)) |
|
51 mt.key = ktyp |
|
52 mt.elem = etyp |
|
53 -- |
|
54 2.7.4 |
|
55 |