Commit 997d7a18 authored by Ian Lance Taylor's avatar Ian Lance Taylor

reflect: remove struct tags from unexported types

Before CL 4281055 in 2011, the reflect package was quite different.
rtype, then called commonType, was embedded in exported structs with
names like StructType. In order to avoid accidental conversions
between pointers to these public structs, which sometimes had
identical fields, the embedded commonType fields were tagged.

In CL 4281055 the formerly public structs were unexported, and all
access was done through the Type interface. At that point the field
tags in the reflect structs were no longer useful.

In Go 1.8 the language was changed to ignore struct field tags when
converting between types. This made the field tags in the reflect
structs doubly useless.

This CL simply removes them.

Fixes #20914

Change-Id: I9af4d6d0709276a91a6b6ee5323cad9dcd0cd0a0
Reviewed-on: https://go-review.googlesource.com/121475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent b410ce75
...@@ -290,9 +290,7 @@ const ( ...@@ -290,9 +290,7 @@ const (
) )
// rtype is the common implementation of most values. // rtype is the common implementation of most values.
// It is embedded in other, public struct types, but always // It is embedded in other struct types.
// with a unique tag like `reflect:"array"` or `reflect:"ptr"`
// so that code cannot convert from, say, *arrayType to *ptrType.
// //
// rtype must be kept in sync with ../runtime/type.go:/^type._type. // rtype must be kept in sync with ../runtime/type.go:/^type._type.
type rtype struct { type rtype struct {
...@@ -350,7 +348,7 @@ const ( ...@@ -350,7 +348,7 @@ const (
// arrayType represents a fixed array type. // arrayType represents a fixed array type.
type arrayType struct { type arrayType struct {
rtype `reflect:"array"` rtype
elem *rtype // array element type elem *rtype // array element type
slice *rtype // slice type slice *rtype // slice type
len uintptr len uintptr
...@@ -358,9 +356,9 @@ type arrayType struct { ...@@ -358,9 +356,9 @@ type arrayType struct {
// chanType represents a channel type. // chanType represents a channel type.
type chanType struct { type chanType struct {
rtype `reflect:"chan"` rtype
elem *rtype // channel element type elem *rtype // channel element type
dir uintptr // channel direction (ChanDir) dir uintptr // channel direction (ChanDir)
} }
// funcType represents a function type. // funcType represents a function type.
...@@ -375,7 +373,7 @@ type chanType struct { ...@@ -375,7 +373,7 @@ type chanType struct {
// [2]*rtype // [0] is in, [1] is out // [2]*rtype // [0] is in, [1] is out
// } // }
type funcType struct { type funcType struct {
rtype `reflect:"func"` rtype
inCount uint16 inCount uint16
outCount uint16 // top bit is set if last input parameter is ... outCount uint16 // top bit is set if last input parameter is ...
} }
...@@ -388,14 +386,14 @@ type imethod struct { ...@@ -388,14 +386,14 @@ type imethod struct {
// interfaceType represents an interface type. // interfaceType represents an interface type.
type interfaceType struct { type interfaceType struct {
rtype `reflect:"interface"` rtype
pkgPath name // import path pkgPath name // import path
methods []imethod // sorted by hash methods []imethod // sorted by hash
} }
// mapType represents a map type. // mapType represents a map type.
type mapType struct { type mapType struct {
rtype `reflect:"map"` rtype
key *rtype // map key type key *rtype // map key type
elem *rtype // map element (value) type elem *rtype // map element (value) type
bucket *rtype // internal bucket structure bucket *rtype // internal bucket structure
...@@ -410,14 +408,14 @@ type mapType struct { ...@@ -410,14 +408,14 @@ type mapType struct {
// ptrType represents a pointer type. // ptrType represents a pointer type.
type ptrType struct { type ptrType struct {
rtype `reflect:"ptr"` rtype
elem *rtype // pointer element (pointed at) type elem *rtype // pointer element (pointed at) type
} }
// sliceType represents a slice type. // sliceType represents a slice type.
type sliceType struct { type sliceType struct {
rtype `reflect:"slice"` rtype
elem *rtype // slice element type elem *rtype // slice element type
} }
// Struct field // Struct field
...@@ -437,7 +435,7 @@ func (f *structField) embedded() bool { ...@@ -437,7 +435,7 @@ func (f *structField) embedded() bool {
// structType represents a struct type. // structType represents a struct type.
type structType struct { type structType struct {
rtype `reflect:"struct"` rtype
pkgPath name pkgPath name
fields []structField // sorted by offset fields []structField // sorted by offset
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment