]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: move emode computation closer to use (cleanup)
authorRobert Griesemer <gri@golang.org>
Mon, 14 Aug 2023 21:15:23 +0000 (14:15 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 15 Aug 2023 19:42:58 +0000 (19:42 +0000)
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>

src/cmd/compile/internal/types2/unify.go
src/go/types/unify.go

index a48f745cb45a05386ba1d00e5f16f689e4b518bf..6a130d55e0883f974e6f1ccef452d9c4e2aae5f6 100644 (file)
@@ -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
index 619459b1ee449e9cf626001404085eb225ee804e..20381215c54e7fd8ca2fe968c5d13851f52853cb 100644 (file)
@@ -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