Skip to content

Commit

Permalink
unbed: reject specifying non-embedded fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mdempsky committed Apr 13, 2017
1 parent 2eff3ef commit 3bf3235
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions unbed.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func main() {
ownerPkg := prog.Package(pkgPath).Pkg
owner = ownerPkg.Scope().Lookup(typeName).(*types.TypeName).Type().Underlying().(*types.Struct)
obj, index, _ := types.LookupFieldOrMethod(owner, false, ownerPkg, fieldName)
if v, ok := obj.(*types.Var); !ok || !v.IsField() || len(index) != 1 {
log.Fatal("expected immediate field name")
if v, ok := obj.(*types.Var); !ok || !v.IsField() || !v.Anonymous() || len(index) != 1 {
log.Fatal("expected immediate embedded field name")
}
fieldIndex = index[0]

Expand Down

0 comments on commit 3bf3235

Please sign in to comment.