Skip to content

Commit

Permalink
Merge pull request #274 from goplus/main
Browse files Browse the repository at this point in the history
bugfix: methodHasAutoProperty bugfix: allow TyOverloadFunc (maybe Gopt_xxx)
  • Loading branch information
xushiwei authored Oct 1, 2023
2 parents 4343141 + c0c3632 commit 5dfcf5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions func_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5dfcf5e

Please sign in to comment.