aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/import.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-11 01:45:24 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-11 14:48:07 +0000
commit4a735ce0680e5ea6088da8072ba4c2b0076e51cb (patch)
treeffc0fd77b0ce448e29575e5d07bcf0789d78eb8a /src/cmd/compile/internal/noder/import.go
parent61888d47c4c49afc2e4ac3aeea42e83cda84d37b (diff)
downloadgo-4a735ce0680e5ea6088da8072ba4c2b0076e51cb.tar.gz
go-4a735ce0680e5ea6088da8072ba4c2b0076e51cb.zip
[dev.typeparams] cmd/compile: add "check" field to noder.gcimports
The unified IR importer needs access to the *types2.Checker instance to lazily construct objects and types. Eventually, maybe the types2.Importer API can be extended to add the Checker as another parameter (or more likely something like an ImportConfig struct), but right now we can handle this ourselves as long as we forgo the types2.(*Config).Check convenience wrapper. Updates #46449. Change-Id: I89c41d5d47c224a58841247cd236cd9f701a23a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/327053 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/import.go')
-rw-r--r--src/cmd/compile/internal/noder/import.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/noder/import.go b/src/cmd/compile/internal/noder/import.go
index 8076b74650..08e3f77b66 100644
--- a/src/cmd/compile/internal/noder/import.go
+++ b/src/cmd/compile/internal/noder/import.go
@@ -31,8 +31,8 @@ import (
"cmd/internal/src"
)
-// Temporary import helper to get type2-based type-checking going.
type gcimports struct {
+ check *types2.Checker
packages map[string]*types2.Package
}
@@ -45,7 +45,7 @@ func (m *gcimports) ImportFrom(path, srcDir string, mode types2.ImportMode) (*ty
panic("mode must be 0")
}
- _, pkg, err := readImportFile(path, typecheck.Target, m.packages)
+ _, pkg, err := readImportFile(path, typecheck.Target, m.check, m.packages)
return pkg, err
}
@@ -176,7 +176,7 @@ func importfile(decl *syntax.ImportDecl) *types.Pkg {
return nil
}
- pkg, _, err := readImportFile(path, typecheck.Target, nil)
+ pkg, _, err := readImportFile(path, typecheck.Target, nil, nil)
if err != nil {
base.Errorf("%s", err)
return nil
@@ -208,7 +208,7 @@ func parseImportPath(pathLit *syntax.BasicLit) (string, error) {
// readImportFile reads the import file for the given package path and
// returns its types.Pkg representation. If packages is non-nil, the
// types2.Package representation is also returned.
-func readImportFile(path string, target *ir.Package, packages map[string]*types2.Package) (pkg1 *types.Pkg, pkg2 *types2.Package, err error) {
+func readImportFile(path string, target *ir.Package, check *types2.Checker, packages map[string]*types2.Package) (pkg1 *types.Pkg, pkg2 *types2.Package, err error) {
path, err = resolveImportPath(path)
if err != nil {
return