mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
784ef4c531
commit
40d5e6d4e2
1 changed files with 11 additions and 3 deletions
|
|
@ -67,13 +67,17 @@ func sanitizeInfo(info *Info) {
|
||||||
type sanitizer map[Type]Type
|
type sanitizer map[Type]Type
|
||||||
|
|
||||||
func (s sanitizer) typ(typ Type) Type {
|
func (s sanitizer) typ(typ Type) Type {
|
||||||
|
if typ == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if t, found := s[typ]; found {
|
if t, found := s[typ]; found {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
s[typ] = typ
|
s[typ] = typ
|
||||||
|
|
||||||
switch t := typ.(type) {
|
switch t := typ.(type) {
|
||||||
case nil, *Basic, *bottom, *top:
|
case *Basic, *bottom, *top:
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
|
||||||
case *Array:
|
case *Array:
|
||||||
|
|
@ -107,10 +111,14 @@ func (s sanitizer) typ(typ Type) Type {
|
||||||
|
|
||||||
case *Interface:
|
case *Interface:
|
||||||
s.funcList(t.methods)
|
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.typeList(t.embeddeds)
|
||||||
s.funcList(t.allMethods)
|
s.funcList(t.allMethods)
|
||||||
s.typ(t.allTypes)
|
if allTypes := s.typ(t.allTypes); allTypes != t.allTypes {
|
||||||
|
t.allTypes = allTypes
|
||||||
|
}
|
||||||
|
|
||||||
case *Map:
|
case *Map:
|
||||||
if key := s.typ(t.key); key != t.key {
|
if key := s.typ(t.key); key != t.key {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue