From a94a6a54d12f8e24ea2db773208f4999b3c6b015 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Sat, 14 Jun 2014 12:45:55 +1000 Subject: [PATCH] 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 --- go/types/typeutil/map.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/types/typeutil/map.go b/go/types/typeutil/map.go index 010df20ccf..69c3f13558 100644 --- a/go/types/typeutil/map.go +++ b/go/types/typeutil/map.go @@ -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)