aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2024-08-08 13:54:56 -0700
committerGopher Robot <gobot@golang.org>2024-08-09 14:40:18 +0000
commit38c766ee0fe22bfcc81e569fccfe9aef2682f63c (patch)
tree05d79b57f772bf60df7721e7815292b2f128c980 /src
parenta01820c7337c0c918da2dae2b2158697683bde50 (diff)
downloadgo-38c766ee0fe22bfcc81e569fccfe9aef2682f63c.tar.xz
types2: move RangeKeyVal func into compilersupport.go
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/types2/compilersupport.go8
-rw-r--r--src/cmd/compile/internal/types2/stmt.go7
2 files changed, 8 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types2/compilersupport.go b/src/cmd/compile/internal/types2/compilersupport.go
index 33dd8e8baa..e98675f9c5 100644
--- a/src/cmd/compile/internal/types2/compilersupport.go
+++ b/src/cmd/compile/internal/types2/compilersupport.go
@@ -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
+}
diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go
index 3027aef2e7..c381187fd3 100644
--- a/src/cmd/compile/internal/types2/stmt.go
+++ b/src/cmd/compile/internal/types2/stmt.go
@@ -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.