]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: allow conversions from type parameter to interface
authorKeith Randall <khr@golang.org>
Sat, 5 Jun 2021 05:54:08 +0000 (22:54 -0700)
committerKeith Randall <khr@golang.org>
Mon, 7 Jun 2021 19:53:38 +0000 (19:53 +0000)
commitcf4b6dc48eba807e7d85fb6ab30cbbbdb143c552
treed7cfb7cb1d50d079b600dda8d81028b8545c5e02
parentbcb3927cb51af39f44d810aab809dff27c950697
[dev.typeparams] cmd/compile: allow conversions from type parameter to interface

When converting from a type param to an interface, allow it if
the type bound implements that interface.

Query: some conversions go through this path, some use another path?
The test does

   var i interface{foo()int} = x

but

   i := (interface{foo()int})(x)

works at tip.

Change-Id: I84d497e5228c0e1d1c9d76ffebaedce09dc45e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/325409
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>
src/cmd/compile/internal/noder/transform.go
src/cmd/compile/internal/typecheck/subr.go
test/typeparam/ifaceconv.go [new file with mode: 0644]