]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: move match function to end of file (cleanup)
authorRobert Griesemer <gri@golang.org>
Sat, 13 Nov 2021 20:04:01 +0000 (12:04 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 15 Nov 2021 21:22:13 +0000 (21:22 +0000)
Change-Id: Ia09f7b1af0e84858fb73ab7e2592c5c3e983dc0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363669
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/type.go

index 3ab738eb19685ab06079918079ca6797f24f62dd..9487ac5a84482ae5edcbc586802cc87cf05f0cf5 100644 (file)
@@ -27,35 +27,6 @@ func under(t Type) Type {
        return t.Underlying()
 }
 
-// If x and y are identical, match returns x.
-// If x and y are identical channels but for their direction
-// and one of them is unrestricted, match returns the channel
-// with the restricted direction.
-// In all other cases, match returns nil.
-func match(x, y Type) Type {
-       // Common case: we don't have channels.
-       if Identical(x, y) {
-               return x
-       }
-
-       // We may have channels that differ in direction only.
-       if x, _ := x.(*Chan); x != nil {
-               if y, _ := y.(*Chan); y != nil && Identical(x.elem, y.elem) {
-                       // We have channels that differ in direction only.
-                       // If there's an unrestricted channel, select the restricted one.
-                       switch {
-                       case x.dir == SendRecv:
-                               return y
-                       case y.dir == SendRecv:
-                               return x
-                       }
-               }
-       }
-
-       // types are different
-       return nil
-}
-
 // If t is not a type parameter, structuralType returns the underlying type.
 // If t is a type parameter, structuralType returns the single underlying
 // type of all types in its type set if it exists, or nil otherwise. If the
@@ -124,3 +95,32 @@ func structuralString(t Type) Type {
        }
        return nil
 }
+
+// If x and y are identical, match returns x.
+// If x and y are identical channels but for their direction
+// and one of them is unrestricted, match returns the channel
+// with the restricted direction.
+// In all other cases, match returns nil.
+func match(x, y Type) Type {
+       // Common case: we don't have channels.
+       if Identical(x, y) {
+               return x
+       }
+
+       // We may have channels that differ in direction only.
+       if x, _ := x.(*Chan); x != nil {
+               if y, _ := y.(*Chan); y != nil && Identical(x.elem, y.elem) {
+                       // We have channels that differ in direction only.
+                       // If there's an unrestricted channel, select the restricted one.
+                       switch {
+                       case x.dir == SendRecv:
+                               return y
+                       case y.dir == SendRecv:
+                               return x
+                       }
+               }
+       }
+
+       // types are different
+       return nil
+}