• Daniel Martí's avatar
    cmd/vet: %s is valid for an array of stringer · 4072608b
    Daniel Martí authored
    vet was quiet for []stringer, but not for [N]stringer. The source of the
    problem was how the recursive call used .Elem().Underlying() for arrays,
    but .Elem() for slices. In the first case, the named type is dropped,
    thus losing all information of attached methods.
    
    Be consistent across slices and arrays, by dropping the Underlying call
    that is causing trouble. Add regression tests too, including cases where
    the element type does not implement fmt.Stringer.
    
    Fixes #23552.
    
    Change-Id: I0fde07d101f112d5768be0a79207ef0b3dc45f2e
    Reviewed-on: https://go-review.googlesource.com/90455
    Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarRob Pike <r@golang.org>
    4072608b
types.go 9.15 KB