3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Test for declaration and use of a parameterized embedded field.
16 type MyStruct[T any] struct {
20 type Lockable[T any] struct {
25 // Get returns the value stored in a Lockable.
26 func (l *Lockable[T]) Get() T {
32 // Set sets the value in a Lockable.
33 func (l *Lockable[T]) Set(v T) {
36 l.MyStruct = MyStruct[T]{v}
43 if got, want := li.Get(), 5; got != want {
44 panic(fmt.Sprintf("got %d, want %d", got, want))