]> Cypherpunks repositories - gostls13.git/commitdiff
types2: move RangeKeyVal func into compilersupport.go
authorRobert Griesemer <gri@golang.org>
Thu, 8 Aug 2024 20:54:56 +0000 (13:54 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 9 Aug 2024 14:40:18 +0000 (14:40 +0000)
This function only exists in types2.

Change-Id: If0a8b6aaf496142cefdf088bd5656536f4ed101c
Reviewed-on: https://go-review.googlesource.com/c/go/+/604276
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/types2/compilersupport.go
src/cmd/compile/internal/types2/stmt.go

index 33dd8e8baace43271c656efcdcd2db74dd89b4d8..e98675f9c587a633ad4f06d281a185d702eeb03f 100644 (file)
@@ -28,3 +28,11 @@ func AsSignature(t Type) *Signature {
 func CoreType(t Type) Type {
        return coreType(t)
 }
+
+// RangeKeyVal returns the key and value types for a range over typ.
+// It panics if range over typ is invalid.
+func RangeKeyVal(typ Type) (Type, Type) {
+       key, val, _, ok := rangeKeyVal(typ, nil)
+       assert(ok)
+       return key, val
+}
index 3027aef2e7a5124d8b1c4bf51d95e298c136e46b..c381187fd3a448d295a1e3e87a992f46d76be84d 100644 (file)
@@ -1001,13 +1001,6 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s
        check.stmt(inner, s.Body)
 }
 
-// RangeKeyVal returns the key and value types for a range over typ.
-// Exported for use by the compiler (does not exist in go/types).
-func RangeKeyVal(typ Type) (Type, Type) {
-       key, val, _, _ := rangeKeyVal(typ, nil)
-       return key, val
-}
-
 // rangeKeyVal returns the key and value type produced by a range clause
 // over an expression of type typ.
 // If allowVersion != nil, it is used to check the required language version.