blob: 1544753ab4928bf4f16c42787269c30b1b45e29f [file] [log] [blame]
Bill Yi7fb3c4c2015-03-23 09:04:07 -07001// run
2
3// Copyright 2014 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// Gccgo chose the wrong embedded method when the same type appeared
8// at different levels and the correct choice was not the first
9// appearance of the type in a depth-first search.
10
11package main
12
13type embedded string
14
15func (s embedded) val() string {
16 return string(s)
17}
18
19type A struct {
20 embedded
21}
22
23type B struct {
24 A
25 embedded
26}
27
28func main() {
29 b := &B{
30 A: A{
31 embedded: "a",
32 },
33 embedded: "b",
34 }
35 s := b.val()
36 if s != "b" {
37 panic(s)
38 }
39}