aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorkorzhao <korzhao95@gmail.com>2021-09-25 15:29:52 +0800
committerDan Scales <danscales@google.com>2021-09-25 17:12:41 +0000
commitaeea5bacbf79fb945edbeac6cd7630dd70c4d9ce (patch)
treeb58d7cf48dc3b415036795b44d46c82e9cd46094 /test/typeparam
parentba7673069d9be4972a864023d74e9e0dd6a77b80 (diff)
downloadgo-aeea5bacbf79fb945edbeac6cd7630dd70c4d9ce.tar.xz
test/typeparam: add a test case for issue48617
For #48617 Change-Id: I6c00b7912c441ac323a0adede63b7d4a9ae6f92d Reviewed-on: https://go-review.googlesource.com/c/go/+/351858 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/issue48617.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/typeparam/issue48617.go b/test/typeparam/issue48617.go
new file mode 100644
index 0000000000..4b00570ba6
--- /dev/null
+++ b/test/typeparam/issue48617.go
@@ -0,0 +1,29 @@
+// run -gcflags=-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 main
+
+type Foo[T any] interface {
+ CreateBar() Bar[T]
+}
+
+type Bar[T any] func() Bar[T]
+
+func (f Bar[T]) CreateBar() Bar[T] {
+ return f
+}
+
+func abc[T any]() {
+ var b Bar[T] = func() Bar[T] {
+ var b Bar[T]
+ return b
+ }
+ var _ Foo[T] = b()
+}
+
+func main() {
+ abc[int]()
+}