Skip to content

Commit 858975d

Browse files
authored
fix: unalias (#93)
1 parent 5aa3287 commit 858975d

File tree

3 files changed

+9
-31
lines changed

3 files changed

+9
-31
lines changed

internal/checkers/checker.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func ExecuteChecker(c Checker, pass *analysis.Pass, call CallContext, cfg Config
2929
nparams := params.Len() // variadic => nonzero
3030
startIndex := nparams - 1
3131

32-
lastArg := params.At(nparams - 1)
33-
if !isTypeVariadicEmptyInterface(lastArg.Type()) {
32+
iface, ok := types.Unalias(params.At(startIndex).Type().(*types.Slice).Elem()).(*types.Interface)
33+
if !ok || !iface.Empty() {
3434
return // final (args) param is not ...interface{}
3535
}
3636

internal/checkers/filter.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package checkers
22

33
import (
44
"go/ast"
5+
"go/types"
56

67
"golang.org/x/tools/go/analysis"
78
)
@@ -13,13 +14,17 @@ func filterKeyAndValues(pass *analysis.Pass, keyAndValues []ast.Expr, objName st
1314
// Skip any object type field we found
1415
switch arg := arg.(type) {
1516
case *ast.CallExpr, *ast.Ident:
16-
typ := pass.TypesInfo.TypeOf(arg)
17+
typ := types.Unalias(pass.TypesInfo.TypeOf(arg))
1718

18-
if typ, ok := typ.(commonAlias); ok {
19+
switch typ := typ.(type) {
20+
case *types.Named:
1921
obj := typ.Obj()
2022
if obj != nil && obj.Name() == objName {
2123
continue
2224
}
25+
26+
default:
27+
// pass
2328
}
2429
}
2530

internal/checkers/types.go

-27
This file was deleted.

0 commit comments

Comments
 (0)