[dev.typeparams] cmd/compile: introduce IsTypeParam() helper

better than Kind() == types.TTYPEPARAM

Change-Id: I4f35a177cd0cda3be615a92b7b2af1b5a60a3bbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325410
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
Keith Randall 2021-06-04 23:01:13 -07:00
parent f0c97219a3
commit bcb3927cb5
5 changed files with 11 additions and 7 deletions

View file

@ -63,7 +63,7 @@ func FixValue(typ *types.Type, val constant.Value) constant.Value {
if !typ.IsUntyped() {
val = typecheck.DefaultLit(ir.NewBasicLit(src.NoXPos, val), typ).Val()
}
if typ.Kind() != types.TTYPEPARAM {
if !typ.IsTypeParam() {
ir.AssertValidTypeForConst(typ, val)
}
return val