aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/lockable.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-05-09 11:38:34 -0700
committerDan Scales <danscales@google.com>2021-05-21 17:03:30 +0000
commitccbfbb1c3327fffe88dd6b6da550f4a0cd37db6e (patch)
treee54eac11914c8444e78acaa5e9f941ce9f3bfdc2 /test/typeparam/lockable.go
parent243076da64d251853ed7a69ce770e9fa71b5bf0d (diff)
downloadgo-ccbfbb1c3327fffe88dd6b6da550f4a0cd37db6e.tar.gz
go-ccbfbb1c3327fffe88dd6b6da550f4a0cd37db6e.zip
[dev.typeparams] cmd/compile: export OFUNCINST and OSELRECV2 nodes (for generic functions)
Added new test typeparam/factimp.go and changed a bunch of other tests to test exporting more generic functions and types. Change-Id: I573d75431cc92482f8f908695cfbc8e84dbb36d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/321749 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/typeparam/lockable.go')
-rw-r--r--test/typeparam/lockable.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/typeparam/lockable.go b/test/typeparam/lockable.go
index d53817521f..3a03652cd8 100644
--- a/test/typeparam/lockable.go
+++ b/test/typeparam/lockable.go
@@ -8,29 +8,29 @@ package main
import "sync"
-// A _Lockable is a value that may be safely simultaneously accessed
+// A Lockable is a value that may be safely simultaneously accessed
// from multiple goroutines via the Get and Set methods.
-type _Lockable[T any] struct {
+type Lockable[T any] struct {
T
mu sync.Mutex
}
-// Get returns the value stored in a _Lockable.
-func (l *_Lockable[T]) get() T {
+// Get returns the value stored in a Lockable.
+func (l *Lockable[T]) get() T {
l.mu.Lock()
defer l.mu.Unlock()
return l.T
}
-// set sets the value in a _Lockable.
-func (l *_Lockable[T]) set(v T) {
+// set sets the value in a Lockable.
+func (l *Lockable[T]) set(v T) {
l.mu.Lock()
defer l.mu.Unlock()
l.T = v
}
func main() {
- sl := _Lockable[string]{T: "a"}
+ sl := Lockable[string]{T: "a"}
if got := sl.get(); got != "a" {
panic(got)
}
@@ -39,7 +39,7 @@ func main() {
panic(got)
}
- il := _Lockable[int]{T: 1}
+ il := Lockable[int]{T: 1}
if got := il.get(); got != 1 {
panic(got)
}