summaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
authorChris Manghane <cmang@golang.org>2014-02-20 11:32:55 -0800
committerChris Manghane <cmang@golang.org>2014-02-20 11:32:55 -0800
commit1da8039be3aa524c85c7b14534b0e80d3ad3cb84 (patch)
treed9b54902f76492afbc8fa5473b403ec54b724c6d /test/fixedbugs
parente63ab6977746ae137408c940cd8eaa76a014ba2b (diff)
downloadgo-1da8039be3aa524c85c7b14534b0e80d3ad3cb84.tar.gz
cmd/gc: make embedded, unexported fields read-only.
Fixes issue 7363. LGTM=gri R=gri, rsc, bradfitz CC=golang-codereviews https://codereview.appspot.com/66510044
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/issue7363.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/fixedbugs/issue7363.go b/test/fixedbugs/issue7363.go
new file mode 100644
index 000000000..726396a7c
--- /dev/null
+++ b/test/fixedbugs/issue7363.go
@@ -0,0 +1,26 @@
+// run
+
+// Copyright 2014 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.
+
+// issue 7363: CanSet must return false for unexported embedded struct fields.
+
+package main
+
+import "reflect"
+
+type a struct {
+}
+
+type B struct {
+ a
+}
+
+func main() {
+ b := &B{}
+ v := reflect.ValueOf(b).Elem().Field(0)
+ if v.CanSet() {
+ panic("B.a is an unexported embedded struct field")
+ }
+}