From 69d945fc6e80475c163f96ba86fe716e77bb0104 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 7 Jul 2021 21:38:49 -0700 Subject: [dev.typeparams] cmd/compile/internal/types2: use scope numbers to identify local types Rather than using a local types' position information, use the type name's scope numbers to uniquely identify the type from others with the same name. We use scope numbers rather than indices (with number-1 == index) to preserve the invariant that the zero value for a scope is a ready to use empty scope. Using scope numbers turned out to be fairly simple after all and provides a reasonably stable identification which will make debugging simpler. A scope number series may be a bit longer than a unique ID for each type name but local types should be reasonably rare. Also did a minor cleanup in universe.go to ensure Named.orig is set up correctly (there's still an open TODO but with a work-around). Change-Id: I73935fa9bd960809fd5c95fe8b8a535c313cfc8f Reviewed-on: https://go-review.googlesource.com/c/go/+/333192 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Go Bot --- src/cmd/compile/internal/types2/subst.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/cmd/compile/internal/types2/subst.go') diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go index 7b4796fa2e..59efe8a045 100644 --- a/src/cmd/compile/internal/types2/subst.go +++ b/src/cmd/compile/internal/types2/subst.go @@ -422,8 +422,6 @@ func (subst *subster) typ(typ Type) Type { var instanceHashing = 0 -// TODO(gri) Eventually, this should be more sophisticated. -// It won't work correctly for locally declared types. func instantiatedHash(typ *Named, targs []Type) string { assert(instanceHashing == 0) instanceHashing++ -- cgit v1.2.3-54-g00ecf