aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/predicates.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-02-01 10:00:29 -0800
committerGopher Robot <gobot@golang.org>2023-02-02 23:40:14 +0000
commit93f5335be96054bd3877cc88e1ddf7d60e5797ef (patch)
tree275a9925541d3760c5af7ccb8b736f6742d37ade /src/go/types/predicates.go
parent683b2c4600c368126b8b00468e55e8e38a58ce1f (diff)
downloadgo-93f5335be96054bd3877cc88e1ddf7d60e5797ef.tar.gz
go-93f5335be96054bd3877cc88e1ddf7d60e5797ef.zip
go/types, types2: enable new type inference
Enable new type inference and compare result with old inference implementation - the result must be identical in a correct program. Change-Id: Ic802d29fcee744f6f826d5e433a3d0c0e73b68e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/464341 Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/go/types/predicates.go')
-rw-r--r--src/go/types/predicates.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go
index 9a156a040c..903b1445e9 100644
--- a/src/go/types/predicates.go
+++ b/src/go/types/predicates.go
@@ -203,7 +203,8 @@ func (p *ifacePair) identical(q *ifacePair) bool {
// A comparer is used to compare types.
type comparer struct {
- ignoreTags bool // if set, identical ignores struct tags
+ ignoreTags bool // if set, identical ignores struct tags
+ ignoreInvalids bool // if set, identical treats an invalid type as identical to any type
}
// For changes to this code the corresponding changes should be made to unifier.nify.
@@ -212,6 +213,10 @@ func (c *comparer) identical(x, y Type, p *ifacePair) bool {
return true
}
+ if c.ignoreInvalids && (x == Typ[Invalid] || y == Typ[Invalid]) {
+ return true
+ }
+
switch x := x.(type) {
case *Basic:
// Basic types are singletons except for the rune and byte