diff options
| author | Robert Griesemer <gri@golang.org> | 2023-08-14 14:15:23 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-08-15 19:42:58 +0000 |
| commit | e95ca9154a6d326248357e87caa4e24368bcb68b (patch) | |
| tree | 37f5c4b2189097e1c74c7f8043a7b6f19ac8d1db | |
| parent | 197522d3ae9e033bc51c5700cf4f7743fb624d8b (diff) | |
| download | go-e95ca9154a6d326248357e87caa4e24368bcb68b.tar.xz | |
go/types, types2: move emode computation closer to use (cleanup)
Follow-up on https://go.dev/cl/519435.
Change-Id: I8febf5544f28acb87607331ff8be8454470328ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/519436
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
| -rw-r--r-- | src/cmd/compile/internal/types2/unify.go | 14 | ||||
| -rw-r--r-- | src/go/types/unify.go | 14 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go index a48f745cb4..6a130d55e0 100644 --- a/src/cmd/compile/internal/types2/unify.go +++ b/src/cmd/compile/internal/types2/unify.go @@ -425,13 +425,6 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) { // x != y if we get here assert(x != y) - // Type elements (array, slice, etc. elements) use emode for unification. - // Element types must match exactly if the types are used in an assignment. - emode := mode - if mode&assign != 0 { - emode |= exact - } - // If we don't require exact unification and both types are interfaces, // one interface must have a subset of the methods of the other and // corresponding method signatures must unify. @@ -547,6 +540,13 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) { x, y = y, x } + // Type elements (array, slice, etc. elements) use emode for unification. + // Element types must match exactly if the types are used in an assignment. + emode := mode + if mode&assign != 0 { + emode |= exact + } + switch x := x.(type) { case *Basic: // Basic types are singletons except for the rune and byte diff --git a/src/go/types/unify.go b/src/go/types/unify.go index 619459b1ee..20381215c5 100644 --- a/src/go/types/unify.go +++ b/src/go/types/unify.go @@ -427,13 +427,6 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) { // x != y if we get here assert(x != y) - // Type elements (array, slice, etc. elements) use emode for unification. - // Element types must match exactly if the types are used in an assignment. - emode := mode - if mode&assign != 0 { - emode |= exact - } - // If we don't require exact unification and both types are interfaces, // one interface must have a subset of the methods of the other and // corresponding method signatures must unify. @@ -549,6 +542,13 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) { x, y = y, x } + // Type elements (array, slice, etc. elements) use emode for unification. + // Element types must match exactly if the types are used in an assignment. + emode := mode + if mode&assign != 0 { + emode |= exact + } + switch x := x.(type) { case *Basic: // Basic types are singletons except for the rune and byte |
