Skip to content

Commit 74be56d

Browse files
committed
Rename reflect.Ptr to reflect.Pointer
This was done in plain Go for 1.18: golang/go@17910ed
1 parent ac7e370 commit 74be56d

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"
@@ -223,7 +226,7 @@ type Type interface {
223226
// Chan: ChanDir, Elem
224227
// Func: In, NumIn, Out, NumOut, IsVariadic.
225228
// Map: Key, Elem
226-
// Ptr: Elem
229+
// Pointer: Elem
227230
// Slice: Elem
228231
// Struct: Field, FieldByIndex, FieldByName, FieldByNameFunc, NumField
229232

@@ -251,7 +254,7 @@ type Type interface {
251254
//IsVariadic() bool
252255

253256
// Elem returns a type's element type.
254-
// It panics if the type's Kind is not Array, Chan, Map, Ptr, or Slice.
257+
// It panics if the type's Kind is not Array, Chan, Map, Pointer, or Slice.
255258
Elem() Type
256259

257260
// Field returns a struct type's i'th field.
@@ -321,13 +324,15 @@ func TypeOf(i interface{}) Type {
321324
return ValueOf(i).typecode
322325
}
323326

324-
func PtrTo(t Type) Type {
325-
if t.Kind() == Ptr {
327+
func PtrTo(t Type) Type { return PointerTo(t) }
328+
329+
func PointerTo(t Type) Type {
330+
if t.Kind() == Pointer {
326331
panic("reflect: cannot make **T type")
327332
}
328333
ptrType := t.(rawType)<<5 | 5 // 0b0101 == 5
329334
if ptrType>>5 != t {
330-
panic("reflect: PtrTo type does not fit")
335+
panic("reflect: PointerTo type does not fit")
331336
}
332337
return ptrType
333338
}
@@ -353,7 +358,7 @@ func (t rawType) Elem() Type {
353358

354359
func (t rawType) elem() rawType {
355360
switch t.Kind() {
356-
case Chan, Ptr, Slice:
361+
case Chan, Pointer, Slice:
357362
return t.stripPrefix()
358363
case Array:
359364
index := t.stripPrefix()
@@ -537,7 +542,7 @@ func (t rawType) Size() uintptr {
537542
return 16
538543
case String:
539544
return unsafe.Sizeof("")
540-
case UnsafePointer, Chan, Map, Ptr:
545+
case UnsafePointer, Chan, Map, Pointer:
541546
return unsafe.Sizeof(uintptr(0))
542547
case Slice:
543548
return unsafe.Sizeof([]int{})
@@ -586,7 +591,7 @@ func (t rawType) Align() int {
586591
return int(unsafe.Alignof(complex128(0)))
587592
case String:
588593
return int(unsafe.Alignof(""))
589-
case UnsafePointer, Chan, Map, Ptr:
594+
case UnsafePointer, Chan, Map, Pointer:
590595
return int(unsafe.Alignof(uintptr(0)))
591596
case Slice:
592597
return int(unsafe.Alignof([]int(nil)))
@@ -652,7 +657,7 @@ func (t rawType) Comparable() bool {
652657
return true
653658
case Interface:
654659
return true
655-
case Ptr:
660+
case Pointer:
656661
return true
657662
case Slice:
658663
return false

0 commit comments

Comments
 (0)