]> Cypherpunks.ru repositories - gostls13.git/commitdiff
reflect: deprecate PtrTo
authorqiulaidongfeng <2645477756@qq.com>
Wed, 26 Jul 2023 05:59:50 +0000 (05:59 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 27 Jul 2023 23:28:51 +0000 (23:28 +0000)
Replace reflect.PtrTo with reflect.PointerTo.

Fixes #59599

Change-Id: I49407193e2050543ef983cd637703acc682d9f51

Change-Id: I49407193e2050543ef983cd637703acc682d9f51
GitHub-Last-Rev: 7bc9ccf1dcb4b444406430b451ad4c47c6ec1be2
GitHub-Pull-Request: golang/go#61440
Reviewed-on: https://go-review.googlesource.com/c/go/+/511035
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
api/next/59599.txt [new file with mode: 0644]
src/cmd/compile/internal/reflectdata/reflect.go
src/encoding/gob/decode.go
src/reflect/type.go

diff --git a/api/next/59599.txt b/api/next/59599.txt
new file mode 100644 (file)
index 0000000..952291f
--- /dev/null
@@ -0,0 +1 @@
+pkg reflect, func PtrTo //deprecated #59599
index 6ef40cb84c0b5b1ba8b9d4f4c23f47cc554e8b15..88a233842e846e0474fadb57e6b10e8ea7032081 100644 (file)
@@ -1224,7 +1224,7 @@ func writeType(t *types.Type) *obj.LSym {
        keep := base.Ctxt.Flag_dynlink
        if !keep && t.Sym() == nil {
                // For an unnamed type, we only need the link if the type can
-               // be created at run time by reflect.PtrTo and similar
+               // be created at run time by reflect.PointerTo and similar
                // functions. If the type exists in the program, those
                // functions must return the existing type structure rather
                // than creating a new one.
index 76ea332e5dee51205c8e1e5d0b44deecf4f50c9a..66c76a070985e8775485359585354c0c87141c69 100644 (file)
@@ -656,7 +656,7 @@ func (dec *Decoder) decodeSlice(state *decoderState, value reflect.Value, elemOp
                errorf("%s slice too big: %d elements of %d bytes", typ.Elem(), u, size)
        }
        if value.Cap() < n {
-               safe := saferio.SliceCap(reflect.Zero(reflect.PtrTo(typ.Elem())).Interface(), uint64(n))
+               safe := saferio.SliceCap(reflect.Zero(reflect.PointerTo(typ.Elem())).Interface(), uint64(n))
                if safe < 0 {
                        errorf("%s slice too big: %d elements of %d bytes", typ.Elem(), u, size)
                }
index 9fd242e732787e362fb2cffcfc1b485053c31a3d..cefb9a43ab41a6d2c343257b43eb5af14dd7eb17 100644 (file)
@@ -1171,6 +1171,8 @@ var ptrMap sync.Map // map[*rtype]*ptrType
 //
 // PtrTo is the old spelling of PointerTo.
 // The two functions behave identically.
+//
+// Deprecated: Superseded by [PointerTo].
 func PtrTo(t Type) Type { return PointerTo(t) }
 
 // PointerTo returns the pointer type with element t.