Skip to content

Commit

Permalink
checkers: fix typeUnparen for func type literals (#1262)
Browse files Browse the repository at this point in the history
Fixes #1245
  • Loading branch information
quasilyte committed Aug 28, 2022
1 parent a38bb6e commit 9fd2b93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion checkers/internal/astwalk/type_expr_walker.go
Expand Up @@ -97,7 +97,10 @@ func (w *typeExprWalker) walk(x ast.Node) bool {

func (w *typeExprWalker) inspectInner(x ast.Expr) bool {
parens, ok := x.(*ast.ParenExpr)
if ok && typep.IsTypeExpr(w.info, parens.X) && astp.IsStarExpr(parens.X) {
shouldInspect := ok &&
typep.IsTypeExpr(w.info, parens.X) &&
(astp.IsStarExpr(parens.X) || astp.IsFuncType(parens.X))
if shouldInspect {
ast.Inspect(parens.X, w.walk)
return false
}
Expand Down
4 changes: 4 additions & 0 deletions checkers/testdata/typeUnparen/negative_tests.go
Expand Up @@ -96,3 +96,7 @@ func channelIssue1035() {
var _ chan (<-chan (chan int))
var _ chan (<-chan (<-chan int))
}

func funcIssue1245() {
_ = (func())(nil)
}

0 comments on commit 9fd2b93

Please sign in to comment.