From 41481388916f53595a30b943cb9cf30d712b9756 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Sun, 15 Jun 2014 10:00:11 +1000 Subject: [PATCH] [release-branch.go1.3] go.tools/go/types/typeutil: use reflect instead of unsafe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ««« 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 --- 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 010df20c..69c3f135 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)