aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/valimp.dir/a.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam/valimp.dir/a.go')
-rw-r--r--test/typeparam/valimp.dir/a.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/typeparam/valimp.dir/a.go b/test/typeparam/valimp.dir/a.go
new file mode 100644
index 0000000000..2ed0063cfd
--- /dev/null
+++ b/test/typeparam/valimp.dir/a.go
@@ -0,0 +1,32 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+type Value[T any] struct {
+ val T
+}
+
+// The noinline directive should survive across import, and prevent instantiations
+// of these functions from being inlined.
+
+//go:noinline
+func Get[T any](v *Value[T]) T {
+ return v.val
+}
+
+//go:noinline
+func Set[T any](v *Value[T], val T) {
+ v.val = val
+}
+
+//go:noinline
+func (v *Value[T]) Set(val T) {
+ v.val = val
+}
+
+//go:noinline
+func (v *Value[T]) Get() T {
+ return v.val
+}