Skip to content

Commit f916b54

Browse files
committed
go/analysis,go/ssa: initialize the types.Info.Instances map
Update a couple places where we should initialize the types.Info.Instances map: - The unitchecker may be used with analyzers that expect the Instances map to be populated. - go/ssa will eventually support instances. Change-Id: Id3dafe57430e5710ee91215a9586b09a87470b15 Reviewed-on: https://go-review.googlesource.com/c/tools/+/357757 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Tim King <[email protected]>
1 parent 1050b5c commit f916b54

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

go/analysis/unitchecker/unitchecker.go

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
"golang.org/x/tools/go/analysis"
5252
"golang.org/x/tools/go/analysis/internal/analysisflags"
5353
"golang.org/x/tools/go/analysis/internal/facts"
54+
"golang.org/x/tools/internal/typeparams"
5455
)
5556

5657
// A Config describes a compilation unit to be analyzed.
@@ -233,6 +234,8 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re
233234
Scopes: make(map[ast.Node]*types.Scope),
234235
Selections: make(map[*ast.SelectorExpr]*types.Selection),
235236
}
237+
typeparams.InitInstanceInfo(info)
238+
236239
pkg, err := tc.Check(cfg.ImportPath, fset, files, info)
237240
if err != nil {
238241
if cfg.SucceedOnTypecheckFailure {

go/ssa/testmain.go

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"os"
2222
"strings"
2323
"text/template"
24+
25+
"golang.org/x/tools/internal/typeparams"
2426
)
2527

2628
// FindTests returns the Test, Benchmark, and Example functions
@@ -180,6 +182,7 @@ func (prog *Program) CreateTestMainPackage(pkg *Package) *Package {
180182
Scopes: make(map[ast.Node]*types.Scope),
181183
Selections: make(map[*ast.SelectorExpr]*types.Selection),
182184
}
185+
typeparams.InitInstanceInfo(info)
183186
testmainPkg, err := conf.Check(path, prog.Fset, files, info)
184187
if err != nil {
185188
log.Fatalf("internal error type-checking %s: %v", path, err)

0 commit comments

Comments
 (0)