• Russ Cox's avatar
    reflect: fix interface to interface conversion in Call · eafa29bd
    Russ Cox authored
    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: 's avatarIan Lance Taylor <iant@golang.org>
    eafa29bd
all_test.go 161 KB