1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00
This commit is contained in:
Entuazism
2024-05-11 20:50:30 +03:00
committed by GitHub
parent 2d3426f777
commit 993c9f68a9
2 changed files with 33 additions and 6 deletions

View File

@@ -138,16 +138,32 @@ func getStructName(r *ast.FieldList) string {
switch v := t.(type) {
case *ast.StarExpr:
t = v.X
return extractFromStarExpr(v)
case *ast.IndexExpr:
t = v.X
return extractFromIndexExpr(v)
case *ast.Ident:
return v.Name
}
if p, _ := t.(*ast.Ident); p != nil {
result = p.Name
}
return defaultStructName
}
return result
func extractFromStarExpr(expr *ast.StarExpr) string {
switch v := expr.X.(type) {
case *ast.IndexExpr:
return extractFromIndexExpr(v)
case *ast.Ident:
return v.Name
}
return defaultStructName
}
func extractFromIndexExpr(expr *ast.IndexExpr) string {
switch v := expr.X.(type) {
case *ast.Ident:
return v.Name
}
return defaultStructName
}
func checkStructFields(fields *ast.FieldList, structName string, w *lintConfusingNames) {

View File

@@ -70,3 +70,14 @@ type y[T any] struct{}
func (y[T]) method() {
}
// issue #982
type a[T any] struct{}
func (x *a[T]) method() {
}
type b[T any] struct{}
func (x *b[T]) method() {
}