aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-06-08 15:58:16 -0700
committerKeith Randall <khr@golang.org>2021-06-29 21:50:53 +0000
commit6a5f7e8498b7cd53bb5461fbf777aa83aea067a8 (patch)
tree6faf2e23ce7e8205af1a6f1db64f4d334639ccca /test/typeparam
parent5fa6bbc669c22f05deb421c324b90b30ae3caa08 (diff)
downloadgo-6a5f7e8498b7cd53bb5461fbf777aa83aea067a8.tar.gz
go-6a5f7e8498b7cd53bb5461fbf777aa83aea067a8.zip
[dev.typeparams] cmd/compile: use dictionary entries for more conversion cases
This CL handles I(x) where I is an interface type and x has typeparam type. Change-Id: Ib99de2b741d588947f5e0164255f6365e98acd8a Reviewed-on: https://go-review.googlesource.com/c/go/+/326189 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/typeparam')
-rw-r--r--test/typeparam/ifaceconv.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/typeparam/ifaceconv.go b/test/typeparam/ifaceconv.go
index 0b0776815c..32c2dbe7c2 100644
--- a/test/typeparam/ifaceconv.go
+++ b/test/typeparam/ifaceconv.go
@@ -38,10 +38,14 @@ func h[T C](x T) interface{foo() int} {
return i
}
func i[T C](x T) C {
- var i C = x
+ var i C = x // conversion in assignment
return i
}
+func j[T C](t T) C {
+ return C(t) // explicit conversion
+}
+
func main() {
if got, want := f[int](7), 7; got != want {
panic(fmt.Sprintf("got %d want %d", got, want))
@@ -55,4 +59,7 @@ func main() {
if got, want := i[myInt](7).foo(), 8; got != want {
panic(fmt.Sprintf("got %d want %d", got, want))
}
+ if got, want := j[myInt](7).foo(), 8; got != want {
+ panic(fmt.Sprintf("got %d want %d", got, want))
+ }
}