1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:14:46 -07:00

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
This commit is contained in:
Andrew Gerrand 2014-06-14 12:45:55 +10:00
parent d46b792624
commit a94a6a54d1

View File

@ -9,7 +9,7 @@ package typeutil
import (
"bytes"
"fmt"
"unsafe"
"reflect"
"code.google.com/p/go.tools/go/types"
)
@ -295,7 +295,7 @@ func (h Hasher) hashFor(t types.Type) uint32 {
case *types.Named:
// 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:
return h.hashTuple(t)