mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove typeparam subscripts, use func/type prefix for uniqueness
In types1 and for the export format, we were using type param subscripts coming from types2 (originally for debugging) to provide unique names. We need unique full-names for type params in types1 to ensure consistent references to type params in function/method bodies and type params derived from translation from types2. We also currently need unique names for type params in importer/iimport.go and gcimporter/iimport.go, because there are no levels of scoping in the package symbol lookup and pkgIndex table. As a step to eliminate the typeparam subscripts (which have no relation to the source code), we change so that the typeparams' unique name is just prefixing the type param name with the name of the enclosing generic function, type, or method. We now no longer use types2.TypeString in types2-to-types1 translation, so Typestring can be changed to eliminate the subscript, as needed. Also, types2.TypeParam.SetId() is no longer needed and is eliminated. We can decide later if we want to do the further step of adding scoping to the importer/iimport.go and gcimporter/iimport.go, which could be used to eliminate the type param "path" prefix from the export format. Change-Id: I0e37795664be2c2e1869b8f9e93393b83fc56409 Reviewed-on: https://go-review.googlesource.com/c/go/+/353135 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
243d65c8e5
commit
0d65c272c9
7 changed files with 44 additions and 65 deletions
|
|
@ -170,6 +170,12 @@ type irgen struct {
|
|||
// avoid adding closures of generic functions/methods to the target.Decls
|
||||
// list.
|
||||
topFuncIsGeneric bool
|
||||
|
||||
// The context during type/function/method declarations that is used to
|
||||
// uniquely name type parameters. We need unique names for type params so we
|
||||
// can be sure they match up correctly between types2-to-types1 translation
|
||||
// and types1 importing.
|
||||
curDecl string
|
||||
}
|
||||
|
||||
func (g *irgen) later(fn func()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue