@@ -308,12 +308,11 @@ func parallelSubtest(info *types.Info, call *ast.CallExpr) []ast.Stmt {
308308 if ! ok {
309309 continue
310310 }
311- expr := exprStmt .X
312- if isMethodCall (info , expr , "testing" , "T" , "Parallel" ) {
313- call , _ := expr .(* ast.CallExpr )
314- if call == nil {
315- continue
316- }
311+ call , ok := exprStmt .X .(* ast.CallExpr )
312+ if ! ok {
313+ continue
314+ }
315+ if isMethodCall (info , call , "testing" , "T" , "Parallel" ) {
317316 x , _ := call .Fun .(* ast.SelectorExpr )
318317 if x == nil {
319318 continue
@@ -347,27 +346,6 @@ func unlabel(stmt ast.Stmt) (ast.Stmt, bool) {
347346 }
348347}
349348
350- // isMethodCall reports whether expr is a method call of
351- // <pkgPath>.<typeName>.<method>.
352- func isMethodCall (info * types.Info , expr ast.Expr , pkgPath , typeName , method string ) bool {
353- call , ok := expr .(* ast.CallExpr )
354- if ! ok {
355- return false
356- }
357-
358- // Check that we are calling a method <method>
359- // TODO(adonovan): use [typesinternal.IsMethodNamed].
360- f := typeutil .StaticCallee (info , call )
361- if f == nil || f .Name () != method {
362- return false
363- }
364- recv := f .Signature ().Recv ()
365- if recv == nil {
366- return false
367- }
368-
369- // Check that the receiver is a <pkgPath>.<typeName> or
370- // *<pkgPath>.<typeName>.
371- _ , named := typesinternal .ReceiverNamed (recv )
372- return typesinternal .IsTypeNamed (named , pkgPath , typeName )
349+ func isMethodCall (info * types.Info , call * ast.CallExpr , pkgPath , typeName , method string ) bool {
350+ return typesinternal .IsMethodNamed (typeutil .Callee (info , call ), pkgPath , typeName , method )
373351}
0 commit comments