Skip to content

Commit dc03839

Browse files
committed
internal/lsp: add additional check for analysis value
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]>
1 parent b1cdfd1 commit dc03839

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/lsp/cache/analysis.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ func (s *snapshot) actionHandle(ctx context.Context, id packageID, mode source.P
131131
err: err,
132132
}
133133
}
134-
data := runAnalysis(ctx, fset, a, pkg, results)
135-
return data
134+
return runAnalysis(ctx, fset, a, pkg, results)
136135
})
137136
ah.handle = h
138137

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

@@ -154,7 +156,10 @@ func (act *actionHandle) cached() ([]*source.Error, interface{}, error) {
154156
if v == nil {
155157
return nil, nil, errors.Errorf("no analyses for %s", act.pkg.ID())
156158
}
157-
data := v.(*actionData)
159+
data, ok := v.(*actionData)
160+
if !ok {
161+
return nil, nil, errors.Errorf("unexpected type for %s:%s", act.pkg.ID(), act.analyzer.Name)
162+
}
158163
return data.diagnostics, data.result, data.err
159164
}
160165

0 commit comments

Comments
 (0)