diff options
author | Robert Griesemer <gri@golang.org> | 2021-08-23 18:29:38 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-08-24 16:36:48 +0000 |
commit | 1ff0554b5318d5a39e2b26a9c84330e6aa47b1c6 (patch) | |
tree | 14a98ed5b571cdf8bcdf847077e7ee04b9869de2 /src/cmd/compile/internal/types2/typestring.go | |
parent | bd9776357732eb3a3c635427bb3591e4cbc79cc5 (diff) | |
download | go-1ff0554b5318d5a39e2b26a9c84330e6aa47b1c6.tar.gz go-1ff0554b5318d5a39e2b26a9c84330e6aa47b1c6.zip |
cmd/compile/internal/types2: use []*TypeParam rather than []*TypeName for type param lists
This is a port of CL 343932 from go/types, with the necessary adjustments
to the compiler.
This change improves type safety slightly, avoids many internal type
assertions, and simplifies some code paths.
Change-Id: Ie9c4734814f49cd248927152d7b3264d3578428c
Reviewed-on: https://go-review.googlesource.com/c/go/+/344614
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/typestring.go')
-rw-r--r-- | src/cmd/compile/internal/types2/typestring.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go index cb7cf73a62..5759118c94 100644 --- a/src/cmd/compile/internal/types2/typestring.go +++ b/src/cmd/compile/internal/types2/typestring.go @@ -242,14 +242,13 @@ func writeTypeList(buf *bytes.Buffer, list []Type, qf Qualifier, visited []Type) } } -func writeTParamList(buf *bytes.Buffer, list []*TypeName, qf Qualifier, visited []Type) { +func writeTParamList(buf *bytes.Buffer, list []*TypeParam, qf Qualifier, visited []Type) { buf.WriteString("[") var prev Type - for i, p := range list { + for i, tpar := range list { // Determine the type parameter and its constraint. // list is expected to hold type parameter names, // but don't crash if that's not the case. - tpar, _ := p.typ.(*TypeParam) var bound Type if tpar != nil { bound = tpar.bound // should not be nil but we want to see it if it is @@ -268,7 +267,7 @@ func writeTParamList(buf *bytes.Buffer, list []*TypeName, qf Qualifier, visited if tpar != nil { writeType(buf, tpar, qf, visited) } else { - buf.WriteString(p.name) + buf.WriteString(tpar.obj.name) } } if prev != nil { |