aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-07-26 17:41:02 -0700
committerKeith Randall <khr@golang.org>2021-07-29 17:15:21 +0000
commitf4f503e0a3ac7fbf9f57c7fe34cecc8df383e334 (patch)
tree397dedaa4096fc324d57593584145d4daf9fdc51 /test
parent4a47e40a14c2051656d4ff4b768fe21a5fc308fa (diff)
downloadgo-f4f503e0a3ac7fbf9f57c7fe34cecc8df383e334.tar.gz
go-f4f503e0a3ac7fbf9f57c7fe34cecc8df383e334.zip
[dev.typeparams] cmd/compile: implement generic .(T) operations
Introduce new dynamic dottype operations which take a dynamic instead of static type to convert to. Change-Id: I5824a1fea056fe811b1226ce059e1e8da1baa335 Reviewed-on: https://go-review.googlesource.com/c/go/+/337609 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/typeparam/dottype.go5
-rw-r--r--test/typeparam/dottype.out2
2 files changed, 7 insertions, 0 deletions
diff --git a/test/typeparam/dottype.go b/test/typeparam/dottype.go
index 89a9b02111..c9c900c096 100644
--- a/test/typeparam/dottype.go
+++ b/test/typeparam/dottype.go
@@ -69,6 +69,11 @@ func main() {
println(h[int](struct{ a, b int }{3, 5}).a)
println(k[int](mybar(3)).bar())
+
+ type large struct {a,b,c,d,e,f int}
+ println(f[large](large{}).a)
+ l2, ok := f2[large](large{})
+ println(l2.a, ok)
}
func shouldpanic(x func()) {
defer func() {
diff --git a/test/typeparam/dottype.out b/test/typeparam/dottype.out
index 058c923a5c..8e6a3c2552 100644
--- a/test/typeparam/dottype.out
+++ b/test/typeparam/dottype.out
@@ -6,3 +6,5 @@
0 false
3
3
+0
+0 true