File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1127,7 +1127,8 @@ dtypesym(Type *t)
1127
1127
ot = dgopkgpath (s , ot , t1 -> sym -> pkg );
1128
1128
} else {
1129
1129
ot = dgostringptr (s , ot , nil );
1130
- if (t1 -> type -> sym != S && t1 -> type -> sym -> pkg == builtinpkg )
1130
+ if (t1 -> type -> sym != S &&
1131
+ (t1 -> type -> sym -> pkg == builtinpkg || !exportname (t1 -> type -> sym -> name )))
1131
1132
ot = dgopkgpath (s , ot , localpkg );
1132
1133
else
1133
1134
ot = dgostringptr (s , ot , nil );
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2014 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ // issue 7363: CanSet must return false for unexported embedded struct fields.
8
+
9
+ package main
10
+
11
+ import "reflect"
12
+
13
+ type a struct {
14
+ }
15
+
16
+ type B struct {
17
+ a
18
+ }
19
+
20
+ func main () {
21
+ b := & B {}
22
+ v := reflect .ValueOf (b ).Elem ().Field (0 )
23
+ if v .CanSet () {
24
+ panic ("B.a is an unexported embedded struct field" )
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments