Skip to content

Commit a84d1dc

Browse files
triariuspolyfloyd
authored andcommitted
refactor: pass extinfo to type assertions
1 parent d2842c5 commit a84d1dc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

errorlint/analysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
4141
lints = append(lints, l...)
4242
}
4343
if checkAsserts {
44-
l := LintErrorTypeAssertions(pass.Fset, *pass.TypesInfo)
44+
l := LintErrorTypeAssertions(pass.Fset, extInfo)
4545
lints = append(lints, l...)
4646
}
4747
if checkErrorf {

errorlint/lint.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,18 @@ func switchComparesNonNil(switchStmt *ast.SwitchStmt) bool {
288288
return false
289289
}
290290

291-
func LintErrorTypeAssertions(fset *token.FileSet, info types.Info) []analysis.Diagnostic {
291+
func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis.Diagnostic {
292292
lints := []analysis.Diagnostic{}
293293

294-
for expr := range info.Types {
294+
for expr := range info.TypesInfo.Types {
295295
// Find type assertions.
296296
typeAssert, ok := expr.(*ast.TypeAssertExpr)
297297
if !ok {
298298
continue
299299
}
300300

301301
// Find type assertions that operate on values of type error.
302-
if !isErrorTypeAssertion(info, typeAssert) {
302+
if !isErrorTypeAssertion(*info.TypesInfo, typeAssert) {
303303
continue
304304
}
305305

@@ -309,7 +309,7 @@ func LintErrorTypeAssertions(fset *token.FileSet, info types.Info) []analysis.Di
309309
})
310310
}
311311

312-
for scope := range info.Scopes {
312+
for scope := range info.TypesInfo.Scopes {
313313
// Find type switches.
314314
typeSwitch, ok := scope.(*ast.TypeSwitchStmt)
315315
if !ok {
@@ -326,7 +326,7 @@ func LintErrorTypeAssertions(fset *token.FileSet, info types.Info) []analysis.Di
326326
}
327327

328328
// Check whether the type switch is on a value of type error.
329-
if !isErrorTypeAssertion(info, typeAssert) {
329+
if !isErrorTypeAssertion(*info.TypesInfo, typeAssert) {
330330
continue
331331
}
332332

0 commit comments

Comments
 (0)