aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/type.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-01-25 09:50:36 -0500
committerRuss Cox <rsc@golang.org>2017-01-25 18:56:51 +0000
commit43c70943861ce39b44e5bd577a8c3c2ef18538db (patch)
tree2a44480a7aaeb4c00eecf97a4c3503683e26e0ef /src/runtime/type.go
parent9657e0b0777f3af3b48908cc39e5ab6d06022422 (diff)
downloadgo-43c70943861ce39b44e5bd577a8c3c2ef18538db.tar.xz
[dev.typealias] reflect: fix StructOf use of StructField to match StructField docs
The runtime internal structField interprets name=="" as meaning anonymous, but the exported reflect.StructField has always set Name, even for anonymous fields, and also set Anonymous=true. The initial implementation of StructOf confused the internal and public meanings of the StructField, expecting the runtime representation of anonymous fields instead of the exported reflect API representation. It also did not document this fact, so that users had no way to know how to create an anonymous field. This CL changes StructOf to use the previously documented interpretation of reflect.StructField instead of an undocumented one. The implementation of StructOf also, in some cases, allowed creating structs with unexported fields (if you knew how to ask) but set the PkgPath incorrectly on those fields. Rather than try to fix that, this CL changes StructOf to reject attempts to create unexported fields. (I think that may be the right design choice, not just a temporary limitation. In any event, it's not the topic for today's work.) For #17766. Fixes #18780. Change-Id: I585a4e324dc5a90551f49d21ae04d2de9ea04b6c Reviewed-on: https://go-review.googlesource.com/35731 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/runtime/type.go')
0 files changed, 0 insertions, 0 deletions