if f.Funarg != FunargNone {
name = Nconv(f.Nname, 0)
} else if flag&FmtLong != 0 {
- name = sconv(s, FmtShort|FmtByte) // qualify non-exported names (used on structs, not on funarg)
+ name = sconv(s, FmtShort|FmtByte)
+ if !exportname(name) && flag&FmtUnsigned == 0 {
+ name = sconv(s, 0) // qualify non-exported names (used on structs, not on funarg)
+ }
} else {
name = sconv(s, 0)
}
pkg := localpkg
if t.Sym != nil {
pkg = t.Sym.Pkg
+ } else {
+ // Unnamed type. Grab the package from the first field, if any.
+ for _, f := range t.Fields().Slice() {
+ if f.Embedded != 0 {
+ continue
+ }
+ pkg = f.Sym.Pkg
+ break
+ }
}
ot = dgopkgpath(s, ot, pkg)
ot = dsymptr(s, ot, s, ot+Widthptr+2*Widthint+uncommonSize(t))
--- /dev/null
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+type V struct{ i int }
--- /dev/null
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package b
+
+import "./a"
+
+var V struct{ i int }
+
+var U struct {
+ a.V
+ j int
+}
--- /dev/null
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "reflect"
+
+ _ "./a"
+ "./b"
+)
+
+var V struct{ i int }
+
+func main() {
+ if got := reflect.ValueOf(b.V).Type().Field(0).PkgPath; got != "b" {
+ panic(`PkgPath=` + got + ` for first field of b.V, want "b"`)
+ }
+ if got := reflect.ValueOf(V).Type().Field(0).PkgPath; got != "main" {
+ panic(`PkgPath=` + got + ` for first field of V, want "main"`)
+ }
+ if got := reflect.ValueOf(b.U).Type().Field(0).PkgPath; got != "b" {
+ panic(`PkgPath=` + got + ` for first field of b.U, want "b"`)
+ }
+}
--- /dev/null
+// compiledir
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Tests that unexported fields of unnamed types have different PkgPath values.
+
+package ignored