Skip to content

Commit

Permalink
fix: unalias (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Oct 30, 2024
1 parent 5aa3287 commit 858975d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
4 changes: 2 additions & 2 deletions internal/checkers/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func ExecuteChecker(c Checker, pass *analysis.Pass, call CallContext, cfg Config
nparams := params.Len() // variadic => nonzero
startIndex := nparams - 1

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

Expand Down
9 changes: 7 additions & 2 deletions internal/checkers/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package checkers

import (
"go/ast"
"go/types"

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

if typ, ok := typ.(commonAlias); ok {
switch typ := typ.(type) {
case *types.Named:
obj := typ.Obj()
if obj != nil && obj.Name() == objName {
continue
}

default:
// pass
}
}

Expand Down
27 changes: 0 additions & 27 deletions internal/checkers/types.go

This file was deleted.

0 comments on commit 858975d

Please sign in to comment.