]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: fix potential bugs in santitizer pass
authorRobert Griesemer <gri@golang.org>
Wed, 5 May 2021 18:54:51 +0000 (11:54 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 5 May 2021 19:15:53 +0000 (19:15 +0000)
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>

src/cmd/compile/internal/types2/sanitize.go

index 8b8bc72d85dd26b86372f94ff595dc1af5b22f6c..64a2dedc7d83d9972af155599757891b41e8a549 100644 (file)
@@ -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 {