aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-04-27 13:10:49 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-04-27 18:07:24 +0000
commitbddfc337f9b053740b51e1fd8429f84dafa89205 (patch)
tree2319aeca11a87efdacc6f2b98853484c2ea36843 /src
parent217be5b35d8fb0f812ca59bf7dec3aa0fb850c46 (diff)
downloadgo-bddfc337f9b053740b51e1fd8429f84dafa89205.tar.xz
reflect: fix strings of SliceOf-created types
The new type was inheriting the tflagExtraStar from its prototype. Fixes #15467 Change-Id: Ic22c2a55cee7580cb59228d52b97e1c0a1e60220 Reviewed-on: https://go-review.googlesource.com/22501 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/reflect/all_test.go3
-rw-r--r--src/reflect/type.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go
index 870ccbf521..f8ffaae8e1 100644
--- a/src/reflect/all_test.go
+++ b/src/reflect/all_test.go
@@ -3902,6 +3902,9 @@ func TestSliceOf(t *testing.T) {
// check construction and use of type not in binary
type T int
st := SliceOf(TypeOf(T(1)))
+ if got, want := st.String(), "[]reflect_test.T"; got != want {
+ t.Errorf("SliceOf(T(1)).String()=%q, want %q", got, want)
+ }
v := MakeSlice(st, 10, 10)
runtime.GC()
for i := 0; i < v.Len(); i++ {
diff --git a/src/reflect/type.go b/src/reflect/type.go
index 0213d56e83..2ceb3d3f66 100644
--- a/src/reflect/type.go
+++ b/src/reflect/type.go
@@ -2251,6 +2251,7 @@ func SliceOf(t Type) Type {
prototype := *(**sliceType)(unsafe.Pointer(&islice))
slice := new(sliceType)
*slice = *prototype
+ slice.tflag = 0
slice.str = resolveReflectName(newName(s, "", "", false))
slice.hash = fnv1(typ.hash, '[')
slice.elem = typ