From: Rob Findley Date: Wed, 5 May 2021 19:01:37 +0000 (-0400) Subject: go/types: fix potential bugs in santitizer pass X-Git-Tag: go1.17beta1~233 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=543e098320;p=gostls13.git go/types: fix potential bugs in santitizer pass 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 Run-TryBot: Robert Findley Reviewed-by: Robert Griesemer --- diff --git a/src/go/types/sanitize.go b/src/go/types/sanitize.go index 3429867321..b905972d36 100644 --- a/src/go/types/sanitize.go +++ b/src/go/types/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 {