Debian Codegraph @

test/fixedbugs/bug485.go

raw
1 // 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
11 package main
12
13 type embedded string
14
15 func (s embedded) val() string {
16 return string(s)
17 }
18
19 type A struct {
20 embedded
21 }
22
23 type B struct {
24 A
25 embedded
26 }
27
28 func 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 }