Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jul 14, 2022
1 parent 328ba3e commit 192db24
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/golinters/goanalysis/runner_loadingpackage.go
Expand Up @@ -121,15 +121,7 @@ func (lp *loadingPackage) loadFromSource(loadMode LoadMode) error {

pkg.IllTyped = true

pkg.TypesInfo = &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),
}
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.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),
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),
}
}
17 changes: 17 additions & 0 deletions pkg/golinters/goanalysis/runner_loadingpackage_ti_go117.go
@@ -0,0 +1,17 @@
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 192db24

Please sign in to comment.