x/tools: modernize interface{} -> any

Produced with a patched version of modernize containing only
the efaceany pass:

$ go run ./gopls/internal/analysis/modernize/cmd/modernize/main.go -test -fix ./... ./gopls/...

This is very safe and forms the bulk of the modernize diff,
isolating the other changes for ease of review.

Change-Id: Iec9352bac5a639a5c03368427531c7842c6e9ad0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/650759
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
Alan Donovan 2025-02-19 17:40:54 -05:00 • committed by Gopher Robot
commit 47e1b0be9d

View file

@ -12,7 +12,7 @@ import (
// ID is a Request identifier.
type ID struct {
value interface{}
value any
}
// Message is the interface to all jsonrpc2 message types.
@ -59,18 +59,18 @@ func Int64ID(i int64) ID { return ID{value: i} }
func (id ID) IsValid() bool { return id.value != nil }
// Raw returns the underlying value of the ID.
func (id ID) Raw() interface{} { return id.value }
func (id ID) Raw() any { return id.value }
// NewNotification constructs a new Notification message for the supplied
// method and parameters.
func NewNotification(method string, params interface{}) (*Request, error) {
func NewNotification(method string, params any) (*Request, error) {
p, merr := marshalToRaw(params)
return &Request{Method: method, Params: p}, merr
}
// NewCall constructs a new Call message for the supplied ID, method and
// parameters.
func NewCall(id ID, method string, params interface{}) (*Request, error) {
func NewCall(id ID, method string, params any) (*Request, error) {
p, merr := marshalToRaw(params)
return &Request{ID: id, Method: method, Params: p}, merr
}
@ -85,7 +85,7 @@ func (msg *Request) marshal(to *wireCombined) {
// NewResponse constructs a new Response message that is a reply to the
// supplied. If err is set result may be ignored.
func NewResponse(id ID, result interface{}, rerr error) (*Response, error) {
func NewResponse(id ID, result any, rerr error) (*Response, error) {
r, merr := marshalToRaw(result)
return &Response{ID: id, Result: r, Error: rerr}, merr
}
@ -169,7 +169,7 @@ func DecodeMessage(data []byte) (Message, error) {
return resp, nil
}
func marshalToRaw(obj interface{}) (json.RawMessage, error) {
func marshalToRaw(obj any) (json.RawMessage, error) {
if obj == nil {
return nil, nil
}