Esempio n. 1
0
func implements(t types.Type, interfac *types.Interface, pkg *types.Package) bool {
	if interfac == nil || t == nil || interfac.Empty() {
		return false
	}
	if types.Implements(t, interfac) {
		return true
	}
	//For some reason, interfaces that comes
	//already built in (not from sources) are
	//not working with types.Implements method
	for i := 0; i < interfac.NumMethods(); i++ {
		m := interfac.Method(i)
		obj, _, _ := types.LookupFieldOrMethod(t, true, pkg, m.Name())
		if obj == nil {
			util.Debug("method %s not found in type %v", m.Name(), t)
			return false
		}
	}
	return true
}