diff --git a/check/check.go b/check/check.go index b1704e4..2bda013 100644 --- a/check/check.go +++ b/check/check.go @@ -908,15 +908,20 @@ func recvPrefix(recv *ast.FieldList) string { } expr = star.X } + + return identName(expr) +} + +func identName(expr ast.Expr) string { switch expr := expr.(type) { case *ast.Ident: return expr.Name + "." case *ast.IndexExpr: - return expr.X.(*ast.Ident).Name + "." + return identName(expr.X) case *ast.ParenExpr: - return expr.X.(*ast.Ident).Name + "." + return identName(expr.X) case *ast.IndexListExpr: - return expr.X.(*ast.Ident).Name + "." + return identName(expr.X) default: panic(fmt.Sprintf("unexpected receiver AST node: %T", expr)) } diff --git a/testdata/script/parenthesized_expression.txtar b/testdata/script/parenthesized_expression.txtar index b544387..cdaf8be 100644 --- a/testdata/script/parenthesized_expression.txtar +++ b/testdata/script/parenthesized_expression.txtar @@ -7,6 +7,7 @@ module testdata.tld/foo go 1.18 -- stdout.golden -- foo.go:7:37: (*FooType).multImplsMethod - a is unused +foo.go:12:44: (*FooType).multImplsMethod2 - a is unused -- foo.go -- package foo @@ -18,3 +19,8 @@ func (f *(FooType)) multImplsMethod(a int) int64 { DoWork() return 3 } + +func (f *((((FooType))))) multImplsMethod2(a int) int64 { + DoWork() + return 3 +}