Commit c48db9a4 authored by Russ Cox's avatar Russ Cox

undo CL 66510044 / 6c0339d94123

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
parent 72185093
...@@ -1138,8 +1138,7 @@ ok: ...@@ -1138,8 +1138,7 @@ ok:
ot = dgopkgpath(s, ot, t1->sym->pkg); ot = dgopkgpath(s, ot, t1->sym->pkg);
} else { } else {
ot = dgostringptr(s, ot, nil); ot = dgostringptr(s, ot, nil);
if(t1->type->sym != S && if(t1->type->sym != S && t1->type->sym->pkg == builtinpkg)
(t1->type->sym->pkg == builtinpkg || !exportname(t1->type->sym->name)))
ot = dgopkgpath(s, ot, localpkg); ot = dgopkgpath(s, ot, localpkg);
else else
ot = dgostringptr(s, ot, nil); ot = dgostringptr(s, ot, nil);
......
// 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")
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment