blob: c99faed43e427d4eb800f5a3c870530c52afb944 [file] [log] [blame]
Ian Lance Taylord3764dd2014-05-06 09:01:38 -04001// run
2
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07003// Copyright 2014 The Go Authors. All rights reserved.
Ian Lance Taylord3764dd2014-05-06 09:01:38 -04004// 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}