diff options
author | Keith Randall <khr@golang.org> | 2021-06-04 23:01:13 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2021-06-07 19:51:26 +0000 |
commit | bcb3927cb51af39f44d810aab809dff27c950697 (patch) | |
tree | 1a09ed62b96fc95c7a46390c75b082b61d0c426f /src/cmd/compile/internal/typecheck/iexport.go | |
parent | f0c97219a3bc5f5c21863c68d4ccf2fb73002d8c (diff) | |
download | go-bcb3927cb51af39f44d810aab809dff27c950697.tar.gz go-bcb3927cb51af39f44d810aab809dff27c950697.zip |
[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>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iexport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iexport.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 6987bc9918..10d4bd6e7e 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -522,7 +522,7 @@ func (p *iexporter) doDecl(n *ir.Name) { } case ir.OTYPE: - if n.Type().Kind() == types.TTYPEPARAM && n.Type().Underlying() == n.Type() { + if n.Type().IsTypeParam() && n.Type().Underlying() == n.Type() { // Even though it has local scope, a typeparam requires a // declaration via its package and unique name, because it // may be referenced within its type bound during its own @@ -898,7 +898,7 @@ func (w *exportWriter) doTyp(t *types.Type) { // The 't.Underlying() == t' check is to confirm this is a base typeparam // type, rather than a defined type with typeparam underlying type, like: // type orderedAbs[T any] T - if t.Kind() == types.TTYPEPARAM && t.Underlying() == t { + if t.IsTypeParam() && t.Underlying() == t { assert(base.Flag.G > 0) if s.Pkg == types.BuiltinPkg || s.Pkg == ir.Pkgs.Unsafe { base.Fatalf("builtin type missing from typIndex: %v", t) @@ -1042,7 +1042,7 @@ func (w *exportWriter) typeList(ts []*types.Type) { func (w *exportWriter) tparamList(fs []*types.Field) { w.uint64(uint64(len(fs))) for _, f := range fs { - if f.Type.Kind() != types.TTYPEPARAM { + if !f.Type.IsTypeParam() { base.Fatalf("unexpected non-typeparam") } w.typ(f.Type) @@ -1095,7 +1095,7 @@ func (w *exportWriter) value(typ *types.Type, v constant.Value) { var kind constant.Kind var valType *types.Type - if typ.Kind() == types.TTYPEPARAM { + if typ.IsTypeParam() { // A constant will have a TYPEPARAM type if it appears in a place // where it must match that typeparam type (e.g. in a binary // operation with a variable of that typeparam type). If so, then |