aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-05-05 11:54:51 -0700
committerRobert Griesemer <gri@golang.org>2021-05-05 19:15:53 +0000
commit40d5e6d4e28eba538ec124d0e437dead63b0206e (patch)
treeb5c4adcf239d5a82b89eb562c115dccf1f5de396 /src/cmd
parent784ef4c53135644d70f3476a4bd90010b9acff66 (diff)
downloadgo-40d5e6d4e28eba538ec124d0e437dead63b0206e.tar.gz
go-40d5e6d4e28eba538ec124d0e437dead63b0206e.zip
cmd/compile/internal/types2: fix potential bugs in santitizer pass
Change-Id: I88c5e1f620d0f3546ac9ac7b6a4b881772a38449 Reviewed-on: https://go-review.googlesource.com/c/go/+/317329 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>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/compile/internal/types2/sanitize.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/types2/sanitize.go b/src/cmd/compile/internal/types2/sanitize.go
index 8b8bc72d85..64a2dedc7d 100644
--- a/src/cmd/compile/internal/types2/sanitize.go
+++ b/src/cmd/compile/internal/types2/sanitize.go
@@ -67,13 +67,17 @@ func sanitizeInfo(info *Info) {
type sanitizer map[Type]Type
func (s sanitizer) typ(typ Type) Type {
+ if typ == nil {
+ return nil
+ }
+
if t, found := s[typ]; found {
return t
}
s[typ] = typ
switch t := typ.(type) {
- case nil, *Basic, *bottom, *top:
+ case *Basic, *bottom, *top:
// nothing to do
case *Array:
@@ -107,10 +111,14 @@ func (s sanitizer) typ(typ Type) Type {
case *Interface:
s.funcList(t.methods)
- s.typ(t.types)
+ if types := s.typ(t.types); types != t.types {
+ t.types = types
+ }
s.typeList(t.embeddeds)
s.funcList(t.allMethods)
- s.typ(t.allTypes)
+ if allTypes := s.typ(t.allTypes); allTypes != t.allTypes {
+ t.allTypes = allTypes
+ }
case *Map:
if key := s.typ(t.key); key != t.key {