]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile/internal/types2: use scope numbers to identify local...
authorRobert Griesemer <gri@golang.org>
Thu, 8 Jul 2021 04:38:49 +0000 (21:38 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 9 Jul 2021 17:36:57 +0000 (17:36 +0000)
commit69d945fc6e80475c163f96ba86fe716e77bb0104
treef299a8ca8176a672a539979c846d2951e0c1d1ad
parent04acb8a7b9fc0212687cc25aa2598d12f6aceb74
[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 <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/compile/internal/types2/instance.go
src/cmd/compile/internal/types2/scope.go
src/cmd/compile/internal/types2/sizeof_test.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/typestring.go
src/cmd/compile/internal/types2/universe.go