]> Cypherpunks repositories - gostls13.git/commit
reflect: fix interface to interface conversion in Call
authorRuss Cox <rsc@golang.org>
Wed, 29 Nov 2017 19:44:43 +0000 (14:44 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 1 Dec 2017 15:31:31 +0000 (15:31 +0000)
commiteafa29bdce13d535d0b121f9b7be5783092d1496
tree3e49a54451d85481e0acf2dc17e7a2a103c4a433
parentf22cf7131a322f958d07c087e8d6a95723262180
reflect: fix interface to interface conversion in Call

Call is meant to mirror the language semantics, which allow:

var r io.ReadWriter
f := func(io.Reader){}
f(r)

even though the conversion from io.ReadWriter to io.Reader is
being applied to a nil interface. This is different from an explicit
conversion:

_ = r.(io.Reader)
f(r.(io.Reader))

Both of those lines panic, but the implicit conversion does not.

By using E2I, which is the implementation of the explicit conversion,
the reflect.Call equivalent of f(r) was inadvertently panicking.
Avoid the panic.

Fixes #22143.

Change-Id: I6b2f5b808e0cd3b89ae8bc75881e307bf1c25558
Reviewed-on: https://go-review.googlesource.com/80736
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/reflect/all_test.go
src/reflect/value.go