aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/type.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-05-06 14:21:47 -0700
committerDan Scales <danscales@google.com>2021-05-13 22:20:18 +0000
commitc3fa51c9a2288ae6441f54e3a59d82015f0b7728 (patch)
tree976620d5929df6727542ea5fb3f6f7cca1324082 /src/cmd/compile/internal/types2/type.go
parent9daf3cca8245a156b02da7bafef42637f8196f88 (diff)
downloadgo-c3fa51c9a2288ae6441f54e3a59d82015f0b7728.tar.gz
go-c3fa51c9a2288ae6441f54e3a59d82015f0b7728.zip
cmd/compile: changed representation of typeparam bound in types1
Especially with typesets, we should be able to fully represent a typeparam bound as just another type (actually an interface type). Change the representation of a typeparam in types1 to include a bound, which is just a type. Changed the signature for NewTypeParam() to take a sym, and not a package, since we always set the sym (name) of the typeparam when creating it. No need for an extra pkg field in Typeparam. Also added index field in the types1 representation of typeparam. This is especially needed to correctly export the typeparam, and re-import it as a types2 type (which requires the index to be set correctly). Change-Id: I50200e2489a97898c37d292b2bd025df790b0277 Reviewed-on: https://go-review.googlesource.com/c/go/+/319929 Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/type.go')
-rw-r--r--src/cmd/compile/internal/types2/type.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go
index e6c260ff67..88dedbad45 100644
--- a/src/cmd/compile/internal/types2/type.go
+++ b/src/cmd/compile/internal/types2/type.go
@@ -760,6 +760,11 @@ func (check *Checker) NewTypeParam(obj *TypeName, index int, bound Type) *TypePa
return typ
}
+// Index returns the index of the type param within its param list.
+func (t *TypeParam) Index() int {
+ return t.index
+}
+
func (t *TypeParam) Bound() *Interface {
iface := asInterface(t.bound)
// use the type bound position if we have one