]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: fix strings of SliceOf-created types
authorDavid Crawshaw <crawshaw@golang.org>
Wed, 27 Apr 2016 17:10:49 +0000 (13:10 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Wed, 27 Apr 2016 18:07:24 +0000 (18:07 +0000)
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>

src/reflect/all_test.go
src/reflect/type.go

index 870ccbf521eb7b58bea8f0dd48c36190cb8204da..f8ffaae8e11e328f4e02141365743440e3b15d44 100644 (file)
@@ -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++ {
index 0213d56e831a23eef7e6a0f9be59cbf755796384..2ceb3d3f661726469a8d65a9ef6456f99a0f48bc 100644 (file)
@@ -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