예제 #1
0
파일: ops.go 프로젝트: pombredanne/go.tools
// checkInterface checks that the method set of x implements the
// interface itype.
// On success it returns "", on failure, an error message.
//
func checkInterface(i *interpreter, itype *types.Interface, x iface) string {
	mset := findMethodSet(i, x.t)
	it := itype.Underlying().(*types.Interface)
	for i, n := 0, it.NumMethods(); i < n; i++ {
		m := it.Method(i)
		id := ssa.MakeId(m.Name(), m.Pkg())
		if mset[id] == nil {
			return fmt.Sprintf("interface conversion: %v is not %v: missing method %v", x.t, itype, id)
		}
	}
	return "" // ok
}