From c48db9a47388bfbcec97d33b03ee81ffe7eb50af Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 14 Apr 2014 09:48:11 -0400 Subject: [PATCH] undo CL 66510044 / 6c0339d94123 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Broke other things - see issue 7522. Fixes #7522. Reopens issue 7363. ««« original CL description cmd/gc: make embedded, unexported fields read-only. Fixes #7363. LGTM=gri R=gri, rsc, bradfitz CC=golang-codereviews https://golang.org/cl/66510044 »»» LGTM=r, mpvl R=golang-codereviews, r CC=golang-codereviews, iant, mpvl https://golang.org/cl/85580046 --- src/cmd/gc/reflect.c | 3 +-- test/fixedbugs/issue7363.go | 26 -------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 test/fixedbugs/issue7363.go diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c index 75d7d8c1c8..af9177f900 100644 --- a/src/cmd/gc/reflect.c +++ b/src/cmd/gc/reflect.c @@ -1138,8 +1138,7 @@ ok: ot = dgopkgpath(s, ot, t1->sym->pkg); } else { ot = dgostringptr(s, ot, nil); - if(t1->type->sym != S && - (t1->type->sym->pkg == builtinpkg || !exportname(t1->type->sym->name))) + if(t1->type->sym != S && t1->type->sym->pkg == builtinpkg) ot = dgopkgpath(s, ot, localpkg); else ot = dgostringptr(s, ot, nil); diff --git a/test/fixedbugs/issue7363.go b/test/fixedbugs/issue7363.go deleted file mode 100644 index 726396a7ce..0000000000 --- a/test/fixedbugs/issue7363.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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") - } -} -- 2.50.0