mirror of
https://github.com/golang/go
synced 2024-11-27 04:21:24 -07:00
go/types, types2: move tparamIndex from unify.go into infer.go
Minor code reorganization: the next version of unify.go doesn't need this function anymore, so move it where it is still used. Change-Id: I6744a2361b5dfe2564ec73787a7a110e85ac9f1d Reviewed-on: https://go-review.googlesource.com/c/go/+/463230 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
21b4e0146a
commit
6b8b7823c7
@ -775,3 +775,18 @@ func (w *cycleFinder) varList(list []*Var) {
|
||||
w.typ(v.typ)
|
||||
}
|
||||
}
|
||||
|
||||
// If tpar is a type parameter in list, tparamIndex returns the type parameter index.
|
||||
// Otherwise, the result is < 0. tpar must not be nil.
|
||||
func tparamIndex(list []*TypeParam, tpar *TypeParam) int {
|
||||
// Once a type parameter is bound its index is >= 0. However, there are some
|
||||
// code paths (namely tracing and type hashing) by which it is possible to
|
||||
// arrive here with a type parameter that has not been bound, hence the check
|
||||
// for 0 <= i below.
|
||||
// TODO(rfindley): investigate a better approach for guarding against using
|
||||
// unbound type parameters.
|
||||
if i := tpar.index; 0 <= i && i < len(list) && list[i] == tpar {
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
@ -156,21 +156,6 @@ func (u *unifier) index(typ Type) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
// If tpar is a type parameter in list, tparamIndex returns the type parameter index.
|
||||
// Otherwise, the result is < 0. tpar must not be nil.
|
||||
func tparamIndex(list []*TypeParam, tpar *TypeParam) int {
|
||||
// Once a type parameter is bound its index is >= 0. However, there are some
|
||||
// code paths (namely tracing and type hashing) by which it is possible to
|
||||
// arrive here with a type parameter that has not been bound, hence the check
|
||||
// for 0 <= i below.
|
||||
// TODO(rfindley): investigate a better approach for guarding against using
|
||||
// unbound type parameters.
|
||||
if i := tpar.index; 0 <= i && i < len(list) && list[i] == tpar {
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// setIndex sets the type slot index for the i'th type parameter
|
||||
// (and all its joined parameters) to tj. The type parameter
|
||||
// must have a (possibly nil) type slot associated with it.
|
||||
|
@ -777,3 +777,18 @@ func (w *cycleFinder) varList(list []*Var) {
|
||||
w.typ(v.typ)
|
||||
}
|
||||
}
|
||||
|
||||
// If tpar is a type parameter in list, tparamIndex returns the type parameter index.
|
||||
// Otherwise, the result is < 0. tpar must not be nil.
|
||||
func tparamIndex(list []*TypeParam, tpar *TypeParam) int {
|
||||
// Once a type parameter is bound its index is >= 0. However, there are some
|
||||
// code paths (namely tracing and type hashing) by which it is possible to
|
||||
// arrive here with a type parameter that has not been bound, hence the check
|
||||
// for 0 <= i below.
|
||||
// TODO(rfindley): investigate a better approach for guarding against using
|
||||
// unbound type parameters.
|
||||
if i := tpar.index; 0 <= i && i < len(list) && list[i] == tpar {
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
@ -158,21 +158,6 @@ func (u *unifier) index(typ Type) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
// If tpar is a type parameter in list, tparamIndex returns the type parameter index.
|
||||
// Otherwise, the result is < 0. tpar must not be nil.
|
||||
func tparamIndex(list []*TypeParam, tpar *TypeParam) int {
|
||||
// Once a type parameter is bound its index is >= 0. However, there are some
|
||||
// code paths (namely tracing and type hashing) by which it is possible to
|
||||
// arrive here with a type parameter that has not been bound, hence the check
|
||||
// for 0 <= i below.
|
||||
// TODO(rfindley): investigate a better approach for guarding against using
|
||||
// unbound type parameters.
|
||||
if i := tpar.index; 0 <= i && i < len(list) && list[i] == tpar {
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// setIndex sets the type slot index for the i'th type parameter
|
||||
// (and all its joined parameters) to tj. The type parameter
|
||||
// must have a (possibly nil) type slot associated with it.
|
||||
|
Loading…
Reference in New Issue
Block a user