@@ -16,7 +16,7 @@ var Analyzer = &analysis.Analyzer{
1616 Requires : []* analysis.Analyzer {inspect .Analyzer },
1717}
1818
19- func run (pass * analysis.Pass ) (interface {} , error ) {
19+ func run (pass * analysis.Pass ) (any , error ) {
2020 insp := pass .ResultOf [inspect .Analyzer ].(* inspector.Inspector )
2121
2222 nodeFilter := []ast.Node {
@@ -50,19 +50,15 @@ func run(pass *analysis.Pass) (interface{}, error) {
5050 }
5151
5252 argsParamType , ok := params [len (params )- 1 ].Type .(* ast.Ellipsis )
53- if ! ok { // args are not ellipsis (...args)
53+ if ! ok {
54+ // args are not ellipsis (...args)
5455 return
5556 }
5657
57- elementType , ok := argsParamType .Elt .(* ast.InterfaceType )
58- if ! ok { // args are not of interface type, but we need interface{}
58+ if ! isAny (argsParamType ) {
5959 return
6060 }
6161
62- if elementType .Methods != nil && len (elementType .Methods .List ) != 0 {
63- return // has >= 1 method in interface, but we need an empty interface "interface{}"
64- }
65-
6662 if strings .HasSuffix (funcDecl .Name .Name , "f" ) {
6763 return
6864 }
@@ -73,3 +69,22 @@ func run(pass *analysis.Pass) (interface{}, error) {
7369
7470 return nil , nil
7571}
72+
73+ func isAny (ell * ast.Ellipsis ) bool {
74+ switch elt := ell .Elt .(type ) {
75+ case * ast.InterfaceType :
76+ if elt .Methods != nil && len (elt .Methods .List ) != 0 {
77+ // has >= 1 method in interface, but we need an empty interface "interface{}"
78+ return false
79+ }
80+
81+ return true
82+
83+ case * ast.Ident :
84+ if elt .Name == "any" {
85+ return true
86+ }
87+ }
88+
89+ return false
90+ }
0 commit comments