diff options
author | Robert Griesemer <gri@golang.org> | 2021-04-13 16:33:42 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-04-14 00:25:33 +0000 |
commit | 8dcc071063c0a9f020f0aafd51b7e0a17f0a0746 (patch) | |
tree | aaf215154c813df7bfaf5f08846b020cf0858515 /src/cmd/compile/internal/types2/types_test.go | |
parent | 34620364cb2ea52e0ebf400a9cda91f86cb38a25 (diff) | |
download | go-8dcc071063c0a9f020f0aafd51b7e0a17f0a0746.tar.gz go-8dcc071063c0a9f020f0aafd51b7e0a17f0a0746.zip |
cmd/compile/internal/types2: use a global atomic counter for type parameter ids
This avoids a dependency on a *Checker when we create type parameters
outside the type checker proper, e.g. in an importer. There may be
better solutions but this does the trick for now.
Change-Id: Icf22c934970cb04c88c2729555ae6a79ef5a2245
Reviewed-on: https://go-review.googlesource.com/c/go/+/309830
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/types_test.go')
-rw-r--r-- | src/cmd/compile/internal/types2/types_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/types_test.go b/src/cmd/compile/internal/types2/types_test.go index 11dca0b53d..096402148d 100644 --- a/src/cmd/compile/internal/types2/types_test.go +++ b/src/cmd/compile/internal/types2/types_test.go @@ -4,6 +4,14 @@ package types2 +import "sync/atomic" + func init() { acceptMethodTypeParams = true } + +// Upon calling ResetId, nextId starts with 1 again. +// It may be called concurrently. This is only needed +// for tests where we may want to have a consistent +// numbering for each individual test case. +func ResetId() { atomic.StoreUint32(&lastId, 0) } |