Skip to content

Commit 0abb298

Browse files
firelizzard18ldez
andauthored
staticcheck: fix generics (#2976)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent d6a39ef commit 0abb298

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

pkg/golinters/goanalysis/runner_loadingpackage.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,7 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {
121121

122122
pkg.IllTyped = true
123123

124-
pkg.TypesInfo = &types.Info{
125-
Types: make(map[ast.Expr]types.TypeAndValue),
126-
Defs: make(map[*ast.Ident]types.Object),
127-
Uses: make(map[*ast.Ident]types.Object),
128-
Implicits: make(map[ast.Node]types.Object),
129-
Scopes: make(map[ast.Node]*types.Scope),
130-
Selections: make(map[*ast.SelectorExpr]*types.Selection),
131-
}
124+
pkg.TypesInfo = newTypesInfo()
132125

133126
importer := func(path string) (*types.Package, error) {
134127
if path == unsafePkgName {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package goanalysis
5+
6+
import (
7+
"go/ast"
8+
"go/types"
9+
)
10+
11+
func newTypesInfo() *types.Info {
12+
return &types.Info{
13+
Types: make(map[ast.Expr]types.TypeAndValue),
14+
Instances: make(map[*ast.Ident]types.Instance),
15+
Defs: make(map[*ast.Ident]types.Object),
16+
Uses: make(map[*ast.Ident]types.Object),
17+
Implicits: make(map[ast.Node]types.Object),
18+
Scopes: make(map[ast.Node]*types.Scope),
19+
Selections: make(map[*ast.SelectorExpr]*types.Selection),
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//go:build go1.17 && !go1.18
2+
// +build go1.17,!go1.18
3+
4+
package goanalysis
5+
6+
import (
7+
"go/ast"
8+
"go/types"
9+
)
10+
11+
func newTypesInfo() *types.Info {
12+
return &types.Info{
13+
Types: make(map[ast.Expr]types.TypeAndValue),
14+
Defs: make(map[*ast.Ident]types.Object),
15+
Uses: make(map[*ast.Ident]types.Object),
16+
Implicits: make(map[ast.Node]types.Object),
17+
Scopes: make(map[ast.Node]*types.Scope),
18+
Selections: make(map[*ast.SelectorExpr]*types.Selection),
19+
}
20+
}

0 commit comments

Comments
 (0)