This is a port of CL 317329 to go/types.
Change-Id: I1ba65284c91044f0ceed536da4149ef25e1f9502
Reviewed-on: https://go-review.googlesource.com/c/go/+/317291
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
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:
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 {