File tree 2 files changed +18
-5
lines changed 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -27,18 +27,17 @@ type packages struct {
27
27
28
28
func (ps * packages ) methodNames (lp * lint.Package ) pkgMethods {
29
29
ps .mu .Lock ()
30
+ defer ps .mu .Unlock ()
30
31
31
32
for _ , pkg := range ps .pkgs {
32
33
if pkg .pkg == lp {
33
- ps .mu .Unlock ()
34
34
return pkg
35
35
}
36
36
}
37
37
38
38
pkgm := pkgMethods {pkg : lp , methods : make (map [string ]map [string ]* referenceMethod ), mu : & sync.Mutex {}}
39
39
ps .pkgs = append (ps .pkgs , pkgm )
40
40
41
- ps .mu .Unlock ()
42
41
return pkgm
43
42
}
44
43
@@ -72,6 +71,7 @@ func (*ConfusingNamingRule) Name() string {
72
71
73
72
// checkMethodName checks if a given method/function name is similar (just case differences) to other method/function of the same struct/file.
74
73
func checkMethodName (holder string , id * ast.Ident , w * lintConfusingNames ) {
74
+
75
75
if id .Name == "init" && holder == defaultStructName {
76
76
// ignore init functions
77
77
return
@@ -137,8 +137,11 @@ func getStructName(r *ast.FieldList) string {
137
137
138
138
t := r .List [0 ].Type
139
139
140
- if p , _ := t .(* ast.StarExpr ); p != nil { // if a pointer receiver => dereference pointer receiver types
141
- t = p .X
140
+ switch v := t .(type ) {
141
+ case * ast.StarExpr :
142
+ t = v .X
143
+ case * ast.IndexExpr :
144
+ t = v .X
142
145
}
143
146
144
147
if p , _ := t .(* ast.Ident ); p != nil {
Original file line number Diff line number Diff line change 1
1
// Test of confusing-naming rule.
2
-
3
2
// Package pkg ...
4
3
package pkg
5
4
@@ -60,3 +59,14 @@ type tBar struct {
60
59
qwe bool
61
60
zxc float32
62
61
}
62
+
63
+ // issue #864
64
+ type x [T any ] struct {}
65
+
66
+ func (x [T ]) method () {
67
+ }
68
+
69
+ type y [T any ] struct {}
70
+
71
+ func (y [T ]) method () {
72
+ }
You can’t perform that action at this time.
0 commit comments