Skip to content

Commit

Permalink
types2: move RangeKeyVal func into compilersupport.go
Browse files Browse the repository at this point in the history
This function only exists in types2.

Change-Id: If0a8b6aaf496142cefdf088bd5656536f4ed101c
Reviewed-on: https://go-review.googlesource.com/c/go/+/604276
Reviewed-by: Robert Griesemer <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
  • Loading branch information
griesemer authored and gopherbot committed Aug 9, 2024
1 parent a01820c commit 38c766e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/cmd/compile/internal/types2/compilersupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 0 additions & 7 deletions src/cmd/compile/internal/types2/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 38c766e

Please sign in to comment.