aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/predicates.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-09-14 18:02:41 -0700
committerGopher Robot <gobot@golang.org>2023-09-15 16:16:58 +0000
commit5914f6a482ce9e178cdc199ec3ec1719b6049f60 (patch)
treed3bacb98d053a99eb89fd3a91df1d5007d13810d /src/cmd/compile/internal/types2/predicates.go
parent5f872db5fc8a05c0b74bea1560595b34c268610a (diff)
downloadgo-5914f6a482ce9e178cdc199ec3ec1719b6049f60.tar.gz
go-5914f6a482ce9e178cdc199ec3ec1719b6049f60.zip
go/types, types2: introduce `isValid` predicate and use throughout
Preparation for Alias type nodes. Using a predicate will ensure that alias indirection can be taken care of when needed, eventually. Change-Id: I689fab6052060eb6bcb2eeac28ba09fdb73f6868 Reviewed-on: https://go-review.googlesource.com/c/go/+/528695 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/predicates.go')
-rw-r--r--src/cmd/compile/internal/types2/predicates.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go
index 872b874ecb..c48f926bf8 100644
--- a/src/cmd/compile/internal/types2/predicates.go
+++ b/src/cmd/compile/internal/types2/predicates.go
@@ -6,6 +6,9 @@
package types2
+// isValid reports whether t is a valid type.
+func isValid(t Type) bool { return t != Typ[Invalid] }
+
// The isX predicates below report whether t is an X.
// If t is a type parameter the result is false; i.e.,
// these predicates don't look inside a type parameter.
@@ -222,7 +225,7 @@ func (c *comparer) identical(x, y Type, p *ifacePair) bool {
return true
}
- if c.ignoreInvalids && (x == Typ[Invalid] || y == Typ[Invalid]) {
+ if c.ignoreInvalids && (!isValid(x) || !isValid(y)) {
return true
}