summaryrefslogtreecommitdiff
path: root/test/bugs/424.dir/main.go
blob: 64a600b55487d90726b2ffb99d112d8bd84cc750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2012 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.

// Tests that method calls through an interface always
// call the the locally defined method localT.m independent
// at which embedding level it is and in which order
// embedding is done.

package main

import "./lib"

type localI interface {
	m() string
}

type localT struct{}

func (t *localT) m() string {
	return "main.localT.m"
}

type myT1 struct {
	localT
}

type myT2 struct {
	localT
	lib.T
}

type myT3 struct {
	lib.T
	localT
}

func main() {
	var i localI

	i = new(localT)
	if i.m() != "main.localT.m" {
		println("BUG: localT:", i.m(), "called")
	}

	i = new(myT1)
	if i.m() != "main.localT.m" {
		println("BUG: myT1:", i.m(), "called")
	}

	i = new(myT2)
	if i.m() != "main.localT.m" {
		println("BUG: myT2:", i.m(), "called")
	}

	i = new(myT3)
	if i.m() != "main.localT.m" {
		println("BUG: myT3:", i.m(), "called")
	}

}