]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: clean up unnecessary comments for rtype
authorJes Cok <xigua67damn@gmail.com>
Thu, 29 Feb 2024 04:40:02 +0000 (04:40 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 4 Mar 2024 17:30:56 +0000 (17:30 +0000)
For consistency, this CL cleans up unnecessary comments,
and moves these Overflow methods to exported area.

For #60427

Change-Id: I14d4ffbc3552d31c211ea1e0b7a0f7090a4a8b89
GitHub-Last-Rev: acdc6ad51bd9ad60a34fdfa8f00a7652cbe34510
GitHub-Pull-Request: golang/go#66019
Reviewed-on: https://go-review.googlesource.com/c/go/+/567917
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/reflect/type.go

index 89f33e6cf85a196d8e915d38e51bd53c10a7a888..16090846992f1615f2310800e9ead1334581b316 100644 (file)
@@ -313,58 +313,6 @@ type rtype struct {
        t abi.Type
 }
 
-// OverflowComplex reports whether the complex128 x cannot be represented by type t.
-// It panics if t's Kind is not Complex64 or Complex128.
-func (t *rtype) OverflowComplex(x complex128) bool {
-       k := t.Kind()
-       switch k {
-       case Complex64:
-               return overflowFloat32(real(x)) || overflowFloat32(imag(x))
-       case Complex128:
-               return false
-       }
-       panic("reflect: OverflowComplex of non-complex type " + t.String())
-}
-
-// OverflowFloat reports whether the float64 x cannot be represented by type t.
-// It panics if t's Kind is not Float32 or Float64.
-func (t *rtype) OverflowFloat(x float64) bool {
-       k := t.Kind()
-       switch k {
-       case Float32:
-               return overflowFloat32(x)
-       case Float64:
-               return false
-       }
-       panic("reflect: OverflowFloat of non-float type " + t.String())
-}
-
-// OverflowInt reports whether the int64 x cannot be represented by type t.
-// It panics if t's Kind is not Int, Int8, Int16, Int32, or Int64.
-func (t *rtype) OverflowInt(x int64) bool {
-       k := t.Kind()
-       switch k {
-       case Int, Int8, Int16, Int32, Int64:
-               bitSize := t.Size() * 8
-               trunc := (x << (64 - bitSize)) >> (64 - bitSize)
-               return x != trunc
-       }
-       panic("reflect: OverflowInt of non-int type " + t.String())
-}
-
-// OverflowUint reports whether the uint64 x cannot be represented by type t.
-// It panics if t's Kind is not Uint, Uintptr, Uint8, Uint16, Uint32, or Uint64.
-func (t *rtype) OverflowUint(x uint64) bool {
-       k := t.Kind()
-       switch k {
-       case Uint, Uintptr, Uint8, Uint16, Uint32, Uint64:
-               bitSize := t.Size() * 8
-               trunc := (x << (64 - bitSize)) >> (64 - bitSize)
-               return x != trunc
-       }
-       panic("reflect: OverflowUint of non-uint type " + t.String())
-}
-
 func (t *rtype) common() *abi.Type {
        return &t.t
 }
@@ -880,6 +828,50 @@ func (t *rtype) IsVariadic() bool {
        return tt.IsVariadic()
 }
 
+func (t *rtype) OverflowComplex(x complex128) bool {
+       k := t.Kind()
+       switch k {
+       case Complex64:
+               return overflowFloat32(real(x)) || overflowFloat32(imag(x))
+       case Complex128:
+               return false
+       }
+       panic("reflect: OverflowComplex of non-complex type " + t.String())
+}
+
+func (t *rtype) OverflowFloat(x float64) bool {
+       k := t.Kind()
+       switch k {
+       case Float32:
+               return overflowFloat32(x)
+       case Float64:
+               return false
+       }
+       panic("reflect: OverflowFloat of non-float type " + t.String())
+}
+
+func (t *rtype) OverflowInt(x int64) bool {
+       k := t.Kind()
+       switch k {
+       case Int, Int8, Int16, Int32, Int64:
+               bitSize := t.Size() * 8
+               trunc := (x << (64 - bitSize)) >> (64 - bitSize)
+               return x != trunc
+       }
+       panic("reflect: OverflowInt of non-int type " + t.String())
+}
+
+func (t *rtype) OverflowUint(x uint64) bool {
+       k := t.Kind()
+       switch k {
+       case Uint, Uintptr, Uint8, Uint16, Uint32, Uint64:
+               bitSize := t.Size() * 8
+               trunc := (x << (64 - bitSize)) >> (64 - bitSize)
+               return x != trunc
+       }
+       panic("reflect: OverflowUint of non-uint type " + t.String())
+}
+
 // add returns p+x.
 //
 // The whySafe string is ignored, so that the function still inlines