aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/types_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-04-13 16:33:42 -0700
committerRobert Griesemer <gri@golang.org>2021-04-14 00:25:33 +0000
commit8dcc071063c0a9f020f0aafd51b7e0a17f0a0746 (patch)
treeaaf215154c813df7bfaf5f08846b020cf0858515 /src/cmd/compile/internal/types2/types_test.go
parent34620364cb2ea52e0ebf400a9cda91f86cb38a25 (diff)
downloadgo-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.go8
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) }