[release-branch.go1.3] go.tools/go/types/typeutil: use reflect instead of unsafe
««« CL 105960043 / 3d86e17d25ff go.tools/go/types/typeutil: use reflect instead of unsafe Godoc depends on this package. Packages that use unsafe cannot be deployed to App Engine. Packages that use reflect can. This package needn't use unsafe, so don't. LGTM=adonovan, rsc R=rsc, adonovan CC=golang-codereviews https://golang.org/cl/105960043 »»» TBR=rsc R=rsc CC=golang-codereviews https://golang.org/cl/104130044
This commit is contained in:
parent
636df8305a
commit
4148138891
|
@ -9,7 +9,7 @@ package typeutil
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
"reflect"
|
||||||
|
|
||||||
"code.google.com/p/go.tools/go/types"
|
"code.google.com/p/go.tools/go/types"
|
||||||
)
|
)
|
||||||
|
@ -295,7 +295,7 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||||
|
|
||||||
case *types.Named:
|
case *types.Named:
|
||||||
// Not safe with a copying GC; objects may move.
|
// Not safe with a copying GC; objects may move.
|
||||||
return uint32(uintptr(unsafe.Pointer(t.Obj())))
|
return uint32(reflect.ValueOf(t.Obj()).Pointer())
|
||||||
|
|
||||||
case *types.Tuple:
|
case *types.Tuple:
|
||||||
return h.hashTuple(t)
|
return h.hashTuple(t)
|
||||||
|
|
Loading…
Reference in New Issue