aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/issue50121.dir/a.go22
-rw-r--r--test/typeparam/issue50121.dir/main.go18
-rw-r--r--test/typeparam/issue50121.go7
3 files changed, 47 insertions, 0 deletions
diff --git a/test/typeparam/issue50121.dir/a.go b/test/typeparam/issue50121.dir/a.go
new file mode 100644
index 0000000000..9918fa38a6
--- /dev/null
+++ b/test/typeparam/issue50121.dir/a.go
@@ -0,0 +1,22 @@
+// 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
+
+import (
+ "constraints"
+ "math/rand"
+)
+
+type Builder[T constraints.Integer] struct{}
+
+func (r Builder[T]) New() T {
+ return T(rand.Int())
+}
+
+var IntBuilder = Builder[int]{}
+
+func BuildInt() int {
+ return IntBuilder.New()
+}
diff --git a/test/typeparam/issue50121.dir/main.go b/test/typeparam/issue50121.dir/main.go
new file mode 100644
index 0000000000..71eb44ff62
--- /dev/null
+++ b/test/typeparam/issue50121.dir/main.go
@@ -0,0 +1,18 @@
+// 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 main
+
+import (
+ "a"
+)
+
+//go:noinline
+func BuildInt() int {
+ return a.BuildInt()
+}
+
+func main() {
+ BuildInt()
+}
diff --git a/test/typeparam/issue50121.go b/test/typeparam/issue50121.go
new file mode 100644
index 0000000000..76930e5e4f
--- /dev/null
+++ b/test/typeparam/issue50121.go
@@ -0,0 +1,7 @@
+// rundir -G=3
+
+// 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 ignored