diff options
author | Robert Griesemer <gri@golang.org> | 2021-11-12 13:23:45 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-11-12 23:26:33 +0000 |
commit | 3a4b95073a9fd7bca6e9fd80016275ef04bc1987 (patch) | |
tree | 2047c9172ffa7fc564ce8741e22d22c50317be77 /src/cmd/compile/internal/types2/predicates.go | |
parent | 429d1e01557f95bba29837f2190441696484fd41 (diff) | |
download | go-3a4b95073a9fd7bca6e9fd80016275ef04bc1987.tar.gz go-3a4b95073a9fd7bca6e9fd80016275ef04bc1987.zip |
cmd/compile/internal/types2: make sure we are safe for nil in underIs
Reviewed all uses of underIs (global function and method) and made
sure we are ok with a nil incoming argument (indicating a type set
with no specific types).
Added a couple of checks where we didn't have them (and somehow
didn't run into a problem yet).
Change-Id: Ifde45a3a80ddf2b1a19c83f79258ad8207dfb09f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363658
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/predicates.go')
-rw-r--r-- | src/cmd/compile/internal/types2/predicates.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index 5cb1c33814..ab490372fc 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -147,7 +147,9 @@ func hasNil(t Type) bool { case *Slice, *Pointer, *Signature, *Interface, *Map, *Chan: return true case *TypeParam: - return u.underIs(hasNil) + return u.underIs(func(u Type) bool { + return u != nil && hasNil(u) + }) } return false } |