1
0

Updated staticcheck

This commit is contained in:
kolaente
2019-04-22 12:59:42 +02:00
parent 5dc1fd0f86
commit 99f83542f6
34 changed files with 6144 additions and 2537 deletions

View File

@ -37,43 +37,46 @@ func sameId(obj types.Object, pkg *types.Package, name string) bool {
return pkg.Path() == obj.Pkg().Path()
}
func (c *Checker) implements(V types.Type, T *types.Interface) bool {
func (g *Graph) implements(V types.Type, T *types.Interface, msV *types.MethodSet) ([]*types.Selection, bool) {
// fast path for common case
if T.Empty() {
return true
return nil, true
}
if ityp, _ := V.Underlying().(*types.Interface); ityp != nil {
// TODO(dh): is this code reachable?
for i := 0; i < T.NumMethods(); i++ {
m := T.Method(i)
_, obj := lookupMethod(ityp, m.Pkg(), m.Name())
switch {
case obj == nil:
return false
return nil, false
case !types.Identical(obj.Type(), m.Type()):
return false
return nil, false
}
}
return true
return nil, true
}
// A concrete type implements T if it implements all methods of T.
ms := c.msCache.MethodSet(V)
var sels []*types.Selection
for i := 0; i < T.NumMethods(); i++ {
m := T.Method(i)
sel := ms.Lookup(m.Pkg(), m.Name())
sel := msV.Lookup(m.Pkg(), m.Name())
if sel == nil {
return false
return nil, false
}
f, _ := sel.Obj().(*types.Func)
if f == nil {
return false
return nil, false
}
if !types.Identical(f.Type(), m.Type()) {
return false
return nil, false
}
sels = append(sels, sel)
}
return true
return sels, true
}

File diff suppressed because it is too large Load Diff