@@ -238,21 +238,26 @@ func (c *Checker) Check() ([]Issue, error) {
238
238
for fn := range allFuncs {
239
239
for _ , b := range fn .Blocks {
240
240
for _ , instr := range b .Instrs {
241
- faddr , ok := instr .(* ssa.FieldAddr )
242
- if ! ok {
243
- continue
244
- }
245
- ftype := faddr .Type ().(* types.Pointer ).Elem ()
246
- if _ , ok := ftype .(* types.Signature ); ! ok {
247
- continue
248
- }
249
- for _ , ref := range * faddr .Referrers () {
250
- store , ok := ref .(* ssa.Store )
251
- if ! ok || store .Addr != faddr {
241
+ switch instr := instr .(type ) {
242
+ case * ssa.Call :
243
+ for _ , arg := range instr .Call .Args {
244
+ if fn := findFunction (arg ); fn != nil {
245
+ c .funcUsedAs [fn ] = "param"
246
+ }
247
+ }
248
+ case * ssa.FieldAddr :
249
+ ftype := instr .Type ().(* types.Pointer ).Elem ()
250
+ if _ , ok := ftype .(* types.Signature ); ! ok {
252
251
continue
253
252
}
254
- if fn , _ := store .Val .(* ssa.Function ); fn != nil {
255
- c .funcUsedAs [fn ] = "field"
253
+ for _ , ref := range * instr .Referrers () {
254
+ store , ok := ref .(* ssa.Store )
255
+ if ! ok || store .Addr != instr {
256
+ continue
257
+ }
258
+ if fn := findFunction (store .Val ); fn != nil {
259
+ c .funcUsedAs [fn ] = "field"
260
+ }
256
261
}
257
262
}
258
263
}
@@ -298,6 +303,17 @@ func (c *Checker) Check() ([]Issue, error) {
298
303
return c .issues , nil
299
304
}
300
305
306
+ // findFunction returns the function that is behind a value, if any.
307
+ func findFunction (value ssa.Value ) * ssa.Function {
308
+ switch value := value .(type ) {
309
+ case * ssa.Function :
310
+ return value
311
+ case * ssa.MakeClosure :
312
+ return value .Fn .(* ssa.Function )
313
+ }
314
+ return nil
315
+ }
316
+
301
317
// addIssue records a newly found unused parameter.
302
318
func (c * Checker ) addIssue (fn * ssa.Function , pos token.Pos , format string , args ... interface {}) {
303
319
c .issues = append (c .issues , Issue {
0 commit comments