]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: qualify unexported fields of unnamed types
authorDavid Crawshaw <crawshaw@golang.org>
Thu, 25 Aug 2016 18:31:50 +0000 (14:31 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 26 Aug 2016 11:46:15 +0000 (11:46 +0000)
commit14efaa0dc3d3ff5a3919c27297297ef0cd5bb625
tree6e8b5735f78acc849dffedd136cb46ac7840e57b
parent3e59b20d41c6dc4ed1e528279da3017555df2ceb
cmd/compile: qualify unexported fields of unnamed types

The compiler was canonicalizing unnamed types of the form

struct { i int }

across packages, even though an unexported field i should not be
accessible from other packages.

The fix requires both qualifying the field name in the string used by
the compiler to distinguish the type, and ensuring the struct's pkgpath
is set in the rtype version of the data when the type being written is
not part of the localpkg.

Fixes #16616

Change-Id: Ibab160b8b5936dfa47b17dbfd48964a65586785b
Reviewed-on: https://go-review.googlesource.com/27791
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/reflect.go
test/fixedbugs/issue16616.dir/a.go [new file with mode: 0644]
test/fixedbugs/issue16616.dir/b.go [new file with mode: 0644]
test/fixedbugs/issue16616.dir/issue16616.go [new file with mode: 0644]
test/fixedbugs/issue16616.go [new file with mode: 0644]