]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: set an origin object for vars and funcs
authorRobert Findley <rfindley@google.com>
Thu, 24 Mar 2022 16:41:25 +0000 (12:41 -0400)
committerRobert Findley <rfindley@google.com>
Tue, 17 May 2022 21:28:43 +0000 (21:28 +0000)
commit1170771074c0792f36fdfe94e50de1dcc8144946
tree51c3b03cebf30c0d00b1081ad06416019aebabce
parent89533024b011bcf41d6de295a5dfb1ad73486abf
go/types, types2: set an origin object for vars and funcs

Historically, Objects in go/types were canonical, meaning each entity
was represented by exactly one variable and could thus be identified by
its address. With object instantiation this is no longer the case: Var
and Func objects must be copied to hold substituted type information,
and there may be more than one Var or Func variable representing the
same source-level entity.

This CL adds Origin methods to *Var and *Func, so users can efficiently
navigate to the corresponding canonical object on the generic type.

Fixes #51682

Change-Id: Ia49e15bd6515e1db1eb3b09b88ba666659601316
Reviewed-on: https://go-review.googlesource.com/c/go/+/395535
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
api/next/51682.txt [new file with mode: 0644]
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/object.go
src/cmd/compile/internal/types2/sizeof_test.go
src/cmd/compile/internal/types2/subst.go
src/go/types/api_test.go
src/go/types/named.go
src/go/types/object.go
src/go/types/sizeof_test.go
src/go/types/subst.go