Skip to content

Commit

Permalink
staticcheck: fix generics (golangci#2976)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
2 people authored and SeigeC committed Apr 4, 2023
1 parent 6c69fae commit ebd0eb2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
9 changes: 1 addition & 8 deletions pkg/golinters/goanalysis/runner_loadingpackage.go
Expand Up @@ -121,14 +121,7 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {

pkg.IllTyped = true

pkg.TypesInfo = &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
Implicits: make(map[ast.Node]types.Object),
Scopes: make(map[ast.Node]*types.Scope),
Selections: make(map[*ast.SelectorExpr]*types.Selection),
}
pkg.TypesInfo = newTypesInfo()

importer := func(path string) (*types.Package, error) {
if path == unsafePkgName {
Expand Down
21 changes: 21 additions & 0 deletions pkg/golinters/goanalysis/runner_loadingpackage_ti.go
@@ -0,0 +1,21 @@
//go:build go1.18
// +build go1.18

package goanalysis

import (
"go/ast"
"go/types"
)

func newTypesInfo() *types.Info {
return &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Instances: make(map[*ast.Ident]types.Instance),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
Implicits: make(map[ast.Node]types.Object),
Scopes: make(map[ast.Node]*types.Scope),
Selections: make(map[*ast.SelectorExpr]*types.Selection),
}
}
20 changes: 20 additions & 0 deletions pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go
@@ -0,0 +1,20 @@
//go:build go1.17 && !go1.18
// +build go1.17,!go1.18

package goanalysis

import (
"go/ast"
"go/types"
)

func newTypesInfo() *types.Info {
return &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
Implicits: make(map[ast.Node]types.Object),
Scopes: make(map[ast.Node]*types.Scope),
Selections: make(map[*ast.SelectorExpr]*types.Selection),
}
}

0 comments on commit ebd0eb2

Please sign in to comment.