1// run
2
3// Copyright 2013 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// issue 6269: name collision on method names for function local types.
8
9package main
10
11type foo struct{}
12
13func (foo) Error() string {
14	return "ok"
15}
16
17type bar struct{}
18
19func (bar) Error() string {
20	return "fail"
21}
22
23func unused() {
24	type collision struct {
25		bar
26	}
27	_ = collision{}
28}
29
30func main() {
31	type collision struct {
32		foo
33	}
34	s := error(collision{})
35	if str := s.Error(); str != "ok" {
36		println("s.Error() ==", str)
37		panic(`s.Error() != "ok"`)
38	}
39}
40