Skip to content

Commit

Permalink
move check for default case inside suggested fix functions
Browse files Browse the repository at this point in the history
  • Loading branch information
martskins committed Feb 7, 2024
1 parent 18d0bb8 commit e2e08f6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gopls/internal/analysis/fillswitch/fillswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func Diagnose(inspect *inspector.Inspector, start, end token.Pos, pkg *types.Pac
return // non-overlapping
}

if defaultHandled(expr.Body) {
return
}

namedType, err := namedTypeFromSwitch(expr, info)
if err != nil {
return
Expand All @@ -79,10 +75,6 @@ func Diagnose(inspect *inspector.Inspector, start, end token.Pos, pkg *types.Pac
return // non-overlapping
}

if defaultHandled(expr.Body) {
return
}

namedType, err := namedTypeFromTypeSwitch(expr, info)
if err != nil {
return
Expand All @@ -109,6 +101,10 @@ func Diagnose(inspect *inspector.Inspector, start, end token.Pos, pkg *types.Pac
}

func suggestedFixTypeSwitch(stmt *ast.TypeSwitchStmt, pkg *types.Package, info *types.Info) (*analysis.SuggestedFix, error) {
if defaultHandled(stmt.Body) {
return nil, nil
}

namedType, err := namedTypeFromTypeSwitch(stmt, info)
if err != nil {
return nil, err
Expand Down Expand Up @@ -163,6 +159,10 @@ func suggestedFixTypeSwitch(stmt *ast.TypeSwitchStmt, pkg *types.Package, info *
}

func suggestedFixSwitch(stmt *ast.SwitchStmt, pkg *types.Package, info *types.Info) (*analysis.SuggestedFix, error) {
if defaultHandled(stmt.Body) {
return nil, nil
}

namedType, err := namedTypeFromSwitch(stmt, info)
if err != nil {
return nil, err
Expand Down

0 comments on commit e2e08f6

Please sign in to comment.