Skip to content

Commit

Permalink
internal/lsp: add additional check for analysis value
Browse files Browse the repository at this point in the history
Updates golang/go#35339

Change-Id: Ie990672b619d1844f66abf62010fe9a69daf00d9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/205161
Run-TryBot: Rebecca Stambler <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Cottrell <[email protected]>
  • Loading branch information
stamblerre committed Nov 4, 2019
1 parent b1cdfd1 commit dc03839
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/lsp/cache/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ func (s *snapshot) actionHandle(ctx context.Context, id packageID, mode source.P
err: err,
}
}
data := runAnalysis(ctx, fset, a, pkg, results)
return data
return runAnalysis(ctx, fset, a, pkg, results)
})
ah.handle = h

Expand All @@ -145,7 +144,10 @@ func (act *actionHandle) analyze(ctx context.Context) ([]*source.Error, interfac
if v == nil {
return nil, nil, errors.Errorf("no analyses for %s", act.pkg.ID())
}
data := v.(*actionData)
data, ok := v.(*actionData)
if !ok {
return nil, nil, errors.Errorf("unexpected type for %s:%s", act.pkg.ID(), act.analyzer.Name)
}
return data.diagnostics, data.result, data.err
}

Expand All @@ -154,7 +156,10 @@ func (act *actionHandle) cached() ([]*source.Error, interface{}, error) {
if v == nil {
return nil, nil, errors.Errorf("no analyses for %s", act.pkg.ID())
}
data := v.(*actionData)
data, ok := v.(*actionData)
if !ok {
return nil, nil, errors.Errorf("unexpected type for %s:%s", act.pkg.ID(), act.analyzer.Name)
}
return data.diagnostics, data.result, data.err
}

Expand Down

0 comments on commit dc03839

Please sign in to comment.