diff --git a/codegen/util.go b/codegen/util.go index 31552cf9815..81bb069deda 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -29,7 +29,7 @@ func findGoType(prog *loader.Program, pkgName string, typeName string) (types.Ob } for astNode, def := range pkg.Defs { - if astNode.Name != typeName || isMethod(def) { + if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { continue } @@ -38,15 +38,6 @@ func findGoType(prog *loader.Program, pkgName string, typeName string) (types.Ob return nil, fmt.Errorf("unable to find type %s\n", fullName) } -func isMethod(t types.Object) bool { - f, isFunc := t.(*types.Func) - if !isFunc { - return false - } - - return f.Type().(*types.Signature).Recv() != nil -} - func findMethod(typ *types.Named, name string) *types.Func { for i := 0; i < typ.NumMethods(); i++ { method := typ.Method(i)