diff --git a/func_ext.go b/func_ext.go index d5378cbb..8737d4b5 100644 --- a/func_ext.go +++ b/func_ext.go @@ -126,8 +126,8 @@ func NewTemplateRecvMethod(typ *types.Named, pos token.Pos, pkg *types.Package, // ---------------------------------------------------------------------------- -func overloadFnHasAutoProperty(v *TyOverloadMethod, n int) bool { - for _, fn := range v.Methods { +func overloadFnHasAutoProperty(fns []types.Object, n int) bool { + for _, fn := range fns { if methodHasAutoProperty(fn.Type(), n) { return true } @@ -141,12 +141,13 @@ func methodHasAutoProperty(typ types.Type, n int) bool { switch t := recv.Type().(type) { case *TyOverloadMethod: // is overload method - return overloadFnHasAutoProperty(t, n) + return overloadFnHasAutoProperty(t.Methods, n) case *TyTemplateRecvMethod: // is template recv method return methodHasAutoProperty(t.Func.Type(), 1) case *TyOverloadFunc: - return false + // is overload func + return overloadFnHasAutoProperty(t.Funcs, n) } } return sig.Params().Len() == n diff --git a/import.go b/import.go index 7c25411d..43fb1f66 100644 --- a/import.go +++ b/import.go @@ -88,10 +88,11 @@ func shouldAddGopPkg(pkg *Package) bool { } func isGopFunc(name string) bool { - if strings.HasPrefix(name, goptPrefix) { - return true - } - return isOverloadFunc(name) + return isOverloadFunc(name) || isGoptFunc(name) +} + +func isGoptFunc(name string) bool { + return strings.HasPrefix(name, goptPrefix) } func isOverloadFunc(name string) bool {