mirror of
https://github.com/golang/net.git
synced 2026-03-31 02:17:08 +09:00
all: use reflect.TypeFor instead of reflect.TypeOf
For golang/go#60088. Change-Id: Ifc6d5cf0b94b977b2699e4781875bf75b9aa25c8 Reviewed-on: https://go-review.googlesource.com/c/net/+/709195 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
@@ -110,7 +110,7 @@ frame:
|
||||
if typ.Kind() != reflect.Func ||
|
||||
typ.NumIn() != 1 ||
|
||||
typ.NumOut() != 1 ||
|
||||
typ.Out(0) != reflect.TypeOf(true) {
|
||||
typ.Out(0) != reflect.TypeFor[bool]() {
|
||||
tf.t.Fatalf("expected func(*SomeFrame) bool, got %T", f)
|
||||
}
|
||||
if typ.In(0) == reflect.TypeOf(fr) {
|
||||
|
||||
@@ -546,9 +546,9 @@ func (p *printer) setAttrPrefix(prefix, url string) {
|
||||
}
|
||||
|
||||
var (
|
||||
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
|
||||
marshalerAttrType = reflect.TypeOf((*MarshalerAttr)(nil)).Elem()
|
||||
textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
|
||||
marshalerType = reflect.TypeFor[Marshaler]()
|
||||
marshalerAttrType = reflect.TypeFor[MarshalerAttr]()
|
||||
textMarshalerType = reflect.TypeFor[encoding.TextMarshaler]()
|
||||
)
|
||||
|
||||
// marshalValue writes one or more XML elements representing val.
|
||||
|
||||
@@ -262,9 +262,9 @@ func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error {
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
|
||||
unmarshalerAttrType = reflect.TypeOf((*UnmarshalerAttr)(nil)).Elem()
|
||||
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
|
||||
unmarshalerType = reflect.TypeFor[Unmarshaler]()
|
||||
unmarshalerAttrType = reflect.TypeFor[UnmarshalerAttr]()
|
||||
textUnmarshalerType = reflect.TypeFor[encoding.TextUnmarshaler]()
|
||||
)
|
||||
|
||||
// Unmarshal a single XML element into val.
|
||||
|
||||
@@ -325,10 +325,10 @@ type BadPathEmbeddedB struct {
|
||||
var badPathTests = []struct {
|
||||
v, e interface{}
|
||||
}{
|
||||
{&BadPathTestA{}, &TagPathError{reflect.TypeOf(BadPathTestA{}), "First", "items>item1", "Second", "items"}},
|
||||
{&BadPathTestB{}, &TagPathError{reflect.TypeOf(BadPathTestB{}), "First", "items>item1", "Second", "items>item1>value"}},
|
||||
{&BadPathTestC{}, &TagPathError{reflect.TypeOf(BadPathTestC{}), "First", "", "Second", "First"}},
|
||||
{&BadPathTestD{}, &TagPathError{reflect.TypeOf(BadPathTestD{}), "First", "", "Second", "First"}},
|
||||
{&BadPathTestA{}, &TagPathError{reflect.TypeFor[BadPathTestA](), "First", "items>item1", "Second", "items"}},
|
||||
{&BadPathTestB{}, &TagPathError{reflect.TypeFor[BadPathTestB](), "First", "items>item1", "Second", "items>item1>value"}},
|
||||
{&BadPathTestC{}, &TagPathError{reflect.TypeFor[BadPathTestC](), "First", "", "Second", "First"}},
|
||||
{&BadPathTestD{}, &TagPathError{reflect.TypeFor[BadPathTestD](), "First", "", "Second", "First"}},
|
||||
}
|
||||
|
||||
func TestUnmarshalBadPaths(t *testing.T) {
|
||||
|
||||
@@ -44,7 +44,7 @@ const (
|
||||
var tinfoMap = make(map[reflect.Type]*typeInfo)
|
||||
var tinfoLock sync.RWMutex
|
||||
|
||||
var nameType = reflect.TypeOf(Name{})
|
||||
var nameType = reflect.TypeFor[Name]()
|
||||
|
||||
// getTypeInfo returns the typeInfo structure with details necessary
|
||||
// for marshalling and unmarshalling typ.
|
||||
|
||||
Reference in New Issue
Block a user