2012-02-16 21:49:30 -07:00
|
|
|
// run
|
2009-07-28 18:01:46 -06:00
|
|
|
|
|
|
|
// Copyright 2009 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.
|
|
|
|
|
|
|
|
package main
|
2011-04-08 10:27:58 -06:00
|
|
|
|
2009-07-28 18:01:46 -06:00
|
|
|
import "reflect"
|
2011-04-08 10:27:58 -06:00
|
|
|
|
|
|
|
type S1 struct{ i int }
|
|
|
|
type S2 struct{ S1 }
|
|
|
|
|
2009-07-28 18:01:46 -06:00
|
|
|
func main() {
|
2011-04-25 11:39:36 -06:00
|
|
|
typ := reflect.TypeOf(S2{})
|
2011-04-08 10:27:58 -06:00
|
|
|
f := typ.Field(0)
|
2009-07-28 18:01:46 -06:00
|
|
|
if f.Name != "S1" || f.Anonymous != true {
|
2011-04-08 10:27:58 -06:00
|
|
|
println("BUG: ", f.Name, f.Anonymous)
|
|
|
|
return
|
2009-07-28 18:01:46 -06:00
|
|
|
}
|
2011-04-08 10:27:58 -06:00
|
|
|
f, ok := typ.FieldByName("S1")
|
2009-07-28 18:01:46 -06:00
|
|
|
if !ok {
|
2011-04-08 10:27:58 -06:00
|
|
|
println("BUG: missing S1")
|
|
|
|
return
|
2009-07-28 18:01:46 -06:00
|
|
|
}
|
|
|
|
if !f.Anonymous {
|
2011-04-08 10:27:58 -06:00
|
|
|
println("BUG: S1 is not anonymous")
|
|
|
|
return
|
2009-07-28 18:01:46 -06:00
|
|
|
}
|
|
|
|
}
|