mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
217be5b35d
commit
bddfc337f9
2 changed files with 4 additions and 0 deletions
|
|
@ -3902,6 +3902,9 @@ func TestSliceOf(t *testing.T) {
|
||||||
// check construction and use of type not in binary
|
// check construction and use of type not in binary
|
||||||
type T int
|
type T int
|
||||||
st := SliceOf(TypeOf(T(1)))
|
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)
|
v := MakeSlice(st, 10, 10)
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
for i := 0; i < v.Len(); i++ {
|
for i := 0; i < v.Len(); i++ {
|
||||||
|
|
|
||||||
|
|
@ -2251,6 +2251,7 @@ func SliceOf(t Type) Type {
|
||||||
prototype := *(**sliceType)(unsafe.Pointer(&islice))
|
prototype := *(**sliceType)(unsafe.Pointer(&islice))
|
||||||
slice := new(sliceType)
|
slice := new(sliceType)
|
||||||
*slice = *prototype
|
*slice = *prototype
|
||||||
|
slice.tflag = 0
|
||||||
slice.str = resolveReflectName(newName(s, "", "", false))
|
slice.str = resolveReflectName(newName(s, "", "", false))
|
||||||
slice.hash = fnv1(typ.hash, '[')
|
slice.hash = fnv1(typ.hash, '[')
|
||||||
slice.elem = typ
|
slice.elem = typ
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue