Repository: mgechev/revive (go)

Issue:
v1.6.0 with Go 1.24: panic: not supported type *ast.InterfaceType
**Describe the bug**

When running revive through the latest release of golangci-lint ([v1.64.2](https://github.com/golangci/golangci-lint/releases/tag/v1.64.2) at the moment of writing), I get the following panic:

```
  Running [/home/runner/golangci-lint-1.64.2-linux-amd64/golangci-lint run --out-format=colored-line-number --timeout=10m] in [/home/runner/work/enterprise-opa-private/enterprise-opa-private] ...
  panic: not supported type *ast.InterfaceType
  
  goroutine 53029 [running]:
  github.com/mgechev/revive/internal/astutils.getFieldTypeName({0x173cb30?, 0xc08a909170?})
  	github.com/mgechev/revive@v1.6.0/internal/astutils/ast_utils.go:75 +0x154
  github.com/mgechev/revive/internal/astutils.getTypeNames(0x0?)
  	github.com/mgechev/revive@v1.6.0/internal/astutils/ast_utils.go:52 +0xa9
  github.com/mgechev/revive/internal/astutils.FuncSignatureIs(0xc009682630, {0x14508bd?, 0x12dd3a0?}, {0xc020aadaf0, 0x0, 0x6?}, {0xc020aadb48, 0x1, 0x0?})
  	github.com/mgechev/revive@v1.6.0/internal/astutils/ast_utils.go:19 +0x8d
  github.com/mgechev/revive/lint.getSortableMethodFlagForFunction(0xc009682630)
  	github.com/mgechev/revive@v1.6.0/lint/package.go:209 +0x69
  github.com/mgechev/revive/lint.(*Package).scanSortable(0xc035528730)
  	github.com/mgechev/revive@v1.6.0/lint/package.go:173 +0x2fa
  github.com/mgechev/revive/lint.(*Package).lint(0xc035528730, {0xc0049bd700, 0x1, 0x1}, {0x0, 0x3fe999999999999a, {0x1457b1f, 0x7}, 0x0, 0xc003df02d0, ...}, ...)
  	github.com/mgechev/revive@v1.6.0/lint/package.go:186 +0x47
  github.com/mgechev/revive/lint.(*Linter).lintPackage(0xc0049bb140, {0xc03adec300, 0xf, 0xc004080f48?}, 0xc0049b9270, {0xc0049bd700, 0x1, 0x1}, {0x0, 0x3fe999999999999a, ...}, ...)
  	github.com/mgechev/revive@v1.6.0/lint/linter.go:158 +0x35b
  github.com/mgechev/revive/lint.(*Linter).Lint.func1()
  	github.com/mgechev/revive@v1.6.0/lint/linter.go:109 +0xa5
  golang.org/x/sync/errgroup.(*Group).Go.func1()
  	golang.org/x/sync@v0.11.0/errgroup/errgroup.go:78 +0x50
  created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 53002
  	golang.org/x/sync@v0.11.0/errgroup/errgroup.go:75 +0x93
  ```

**To Reproduce**

⚠ I need help here, I'm running this in a large repository -- how can I help isolating the sources that lead to this?

**Expected behavior**
No panic. This seems similar, but not identical to #1217.

**Logs**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: Github runner, Ubuntu 22.04.5
 - Go 1.24

**Additional context**

The problem is related to Go 1.24, we had been using your fine linter through golangci-lint for a long time ✨ Thanks for working on this!

Pull request:
fix: panic with getFieldTypeName

Closes #1228

Patch:
diff --git a/internal/astutils/ast_utils.go b/internal/astutils/ast_utils.go
index bcd13d8..0a34604 100644
--- a/internal/astutils/ast_utils.go
+++ b/internal/astutils/ast_utils.go
@@ -2,7 +2,6 @@
 package astutils
 
 import (
-	"fmt"
 	"go/ast"
 )
 
@@ -73,7 +72,11 @@ func getFieldTypeName(typ ast.Expr) string {
 		return "*" + getFieldTypeName(f.X)
 	case *ast.IndexExpr:
 		return getFieldTypeName(f.X) + "[" + getFieldTypeName(f.Index) + "]"
+	case *ast.ArrayType:
+		return "[]" + getFieldTypeName(f.Elt)
+	case *ast.InterfaceType:
+		return "interface{}"
 	default:
-		panic(fmt.Sprintf("not supported type %T", typ))
+		return "UNHANDLED_TYPE"
 	}
 }


Test patch:
diff --git a/testdata/golint/sort.go b/testdata/golint/sort.go
index e4e5c98..e82057a 100644
--- a/testdata/golint/sort.go
+++ b/testdata/golint/sort.go
@@ -44,3 +44,12 @@ func (x X) Less(i *pkg.tip) (result bool) { return len(x) } // MATCH /exported m
 
 // Test for issue #1217
 func (s *synchronized[T]) Swap(other Synchronized[T]) {}
+
+// Swap for issue #1228
+func (s *synchronized[T]) Swap(other interface{}) {}
+
+// Swap for issue #1228
+func (s *synchronized[T]) Swap(other []int) {}
+
+// Swap for issue #1228
+func (s *synchronized[T]) Swap(other []interface{}) {}