1
0
mirror of https://github.com/golang/go synced 2024-10-01 09:38:36 -06:00
go/ssa/interp/testdata/ifaceprom.go
Alan Donovan 1f2812fe9b go.tools/ssa: fix bug in makeBridgeMethod for promoted interfaces.
The method index was hard-coded to zero, which works some of
the time.  Apparently I just forgot to implement the
method-table lookup...

Added regression test.

R=gri
CC=golang-dev
https://golang.org/cl/9916043
2013-05-31 16:36:03 -04:00

36 lines
474 B
Go

package main
// Test of promotion of methods of an interface embedded within a
// struct. In particular, this test excercises that the correct
// method is called.
type I interface {
one() int
two() string
}
type S struct {
I
}
type impl struct{}
func (impl) one() int {
return 1
}
func (impl) two() string {
return "two"
}
func main() {
var s S
s.I = impl{}
if one := s.one(); one != 1 {
panic(one)
}
if two := s.two(); two != "two" {
panic(two)
}
}