Skip to content

Commit 51d538b

Browse files
QuLogicdeadprogram
authored andcommitted
Rename reflect.Ptr to reflect.Pointer
This was done in plain Go for 1.18: golang/go@17910ed
1 parent a8b3fa1 commit 51d538b

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/reflect/type.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// if set) and xxx contains the type kind number:
1919
// 0 (0001): Chan
2020
// 1 (0011): Interface
21-
// 2 (0101): Ptr
21+
// 2 (0101): Pointer
2222
// 3 (0111): Slice
2323
// 4 (1001): Array
2424
// 5 (1011): Func
@@ -54,14 +54,17 @@ const (
5454
UnsafePointer
5555
Chan
5656
Interface
57-
Ptr
57+
Pointer
5858
Slice
5959
Array
6060
Func
6161
Map
6262
Struct
6363
)
6464

65+
// Ptr is the old name for the Pointer kind.
66+
const Ptr = Pointer
67+
6568
func (k Kind) String() string {
6669
switch k {
6770
case Bool:
@@ -104,7 +107,7 @@ func (k Kind) String() string {
104107
return "chan"
105108
case Interface:
106109
return "interface"
107-
case Ptr:
110+
case Pointer:
108111
return "ptr"
109112
case Slice:
110113
return "slice"
@@ -252,7 +255,7 @@ type Type interface {
252255
// Chan: ChanDir, Elem
253256
// Func: In, NumIn, Out, NumOut, IsVariadic.
254257
// Map: Key, Elem
255-
// Ptr: Elem
258+
// Pointer: Elem
256259
// Slice: Elem
257260
// Struct: Field, FieldByIndex, FieldByName, FieldByNameFunc, NumField
258261

@@ -280,7 +283,7 @@ type Type interface {
280283
IsVariadic() bool
281284

282285
// Elem returns a type's element type.
283-
// It panics if the type's Kind is not Array, Chan, Map, Ptr, or Slice.
286+
// It panics if the type's Kind is not Array, Chan, Map, Pointer, or Slice.
284287
Elem() Type
285288

286289
// Field returns a struct type's i'th field.
@@ -350,13 +353,15 @@ func TypeOf(i interface{}) Type {
350353
return ValueOf(i).typecode
351354
}
352355

353-
func PtrTo(t Type) Type {
354-
if t.Kind() == Ptr {
356+
func PtrTo(t Type) Type { return PointerTo(t) }
357+
358+
func PointerTo(t Type) Type {
359+
if t.Kind() == Pointer {
355360
panic("reflect: cannot make **T type")
356361
}
357362
ptrType := t.(rawType)<<5 | 5 // 0b0101 == 5
358363
if ptrType>>5 != t {
359-
panic("reflect: PtrTo type does not fit")
364+
panic("reflect: PointerTo type does not fit")
360365
}
361366
return ptrType
362367
}
@@ -382,7 +387,7 @@ func (t rawType) Elem() Type {
382387

383388
func (t rawType) elem() rawType {
384389
switch t.Kind() {
385-
case Chan, Ptr, Slice:
390+
case Chan, Pointer, Slice:
386391
return t.stripPrefix()
387392
case Array:
388393
index := t.stripPrefix()
@@ -566,7 +571,7 @@ func (t rawType) Size() uintptr {
566571
return 16
567572
case String:
568573
return unsafe.Sizeof("")
569-
case UnsafePointer, Chan, Map, Ptr:
574+
case UnsafePointer, Chan, Map, Pointer:
570575
return unsafe.Sizeof(uintptr(0))
571576
case Slice:
572577
return unsafe.Sizeof([]int{})
@@ -615,7 +620,7 @@ func (t rawType) Align() int {
615620
return int(unsafe.Alignof(complex128(0)))
616621
case String:
617622
return int(unsafe.Alignof(""))
618-
case UnsafePointer, Chan, Map, Ptr:
623+
case UnsafePointer, Chan, Map, Pointer:
619624
return int(unsafe.Alignof(uintptr(0)))
620625
case Slice:
621626
return int(unsafe.Alignof([]int(nil)))
@@ -681,7 +686,7 @@ func (t rawType) Comparable() bool {
681686
return true
682687
case Interface:
683688
return true
684-
case Ptr:
689+
case Pointer:
685690
return true
686691
case Slice:
687692
return false

0 commit comments

Comments
 (0)