aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-26 12:13:45 -0700
committerRobert Griesemer <gri@golang.org>2021-07-26 20:53:17 +0000
commit37d2219960340614f4d7e67c2e620013594e131a (patch)
treedecd8d783ed931343c58b3d69e18c2b912b86f0b /test/typeparam
parentd6753fd491c101e71f5e86d87b44d396828e2deb (diff)
downloadgo-37d2219960340614f4d7e67c2e620013594e131a.tar.gz
go-37d2219960340614f4d7e67c2e620013594e131a.zip
[dev.typeparams] cmd/compile/internal/types2: embedded type cannot be a (pointer to) a type parameter
Change-Id: I5eb03ae349925f0799dd866e207221429bc9fb3c Reviewed-on: https://go-review.googlesource.com/c/go/+/337353 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/interfacearg.go10
-rw-r--r--test/typeparam/lockable.go10
2 files changed, 10 insertions, 10 deletions
diff --git a/test/typeparam/interfacearg.go b/test/typeparam/interfacearg.go
index e2d85e3647..1d19499318 100644
--- a/test/typeparam/interfacearg.go
+++ b/test/typeparam/interfacearg.go
@@ -9,14 +9,14 @@ package main
type I interface{}
type _S[T any] struct {
- *T
+ x *T
}
// F is a non-generic function, but has a type _S[I] which is instantiated from a
// generic type. Test that _S[I] is successfully exported.
func F() {
v := _S[I]{}
- if v.T != nil {
+ if v.x != nil {
panic(v)
}
}
@@ -33,9 +33,9 @@ func _F1[T interface{ M() }](t T) {
}
func F2() {
- _F1(&S1{})
- _F1(S2{})
- _F1(&S2{})
+ _F1(&S1{})
+ _F1(S2{})
+ _F1(&S2{})
}
func main() {
diff --git a/test/typeparam/lockable.go b/test/typeparam/lockable.go
index 3a03652cd8..9372c76b4d 100644
--- a/test/typeparam/lockable.go
+++ b/test/typeparam/lockable.go
@@ -11,7 +11,7 @@ import "sync"
// 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 {
- T
+ x T
mu sync.Mutex
}
@@ -19,18 +19,18 @@ type Lockable[T any] struct {
func (l *Lockable[T]) get() T {
l.mu.Lock()
defer l.mu.Unlock()
- return l.T
+ return l.x
}
// set sets the value in a Lockable.
func (l *Lockable[T]) set(v T) {
l.mu.Lock()
defer l.mu.Unlock()
- l.T = v
+ l.x = v
}
func main() {
- sl := Lockable[string]{T: "a"}
+ sl := Lockable[string]{x: "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]{x: 1}
if got := il.get(); got != 1 {
panic(got)
}