aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/typexpr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-01-26 12:08:18 -0800
committerRobert Griesemer <gri@golang.org>2021-01-27 19:42:42 +0000
commit217a461f56cecee1756bef29f9ad2dcd389a255b (patch)
tree8917d7d61a7645069c0d6296b9e2570c3a8241ba /src/cmd/compile/internal/types2/typexpr.go
parent08a598f8c1c123fda3b7ad30659fa05a8be1ccde (diff)
downloadgo-217a461f56cecee1756bef29f9ad2dcd389a255b.tar.gz
go-217a461f56cecee1756bef29f9ad2dcd389a255b.zip
[dev.typeparams] cmd/compile/internal/types2: report unused packages in source order
1) Rather than map-iterate through all file scopes and collect unused packages, collect all imports in the Checker.imports list so that errors are reported in source order. 2) From cmd/compile, borrow the idea of a "dotImportRefs" map to map dot-imported objects to the package they were dot-imported through (we call the map "dotImportMap"). 3) From cmd/compile, borrow the "pkgnotused" function (called Checker.errorUnusedPkg in this code) and clean up unused package error reporting. 4) Adjust unused package error message to match compiler message exactly. 5) Enable one more excluded test case in test/run.go. Change-Id: I4e4e55512a6043a7fd54f576c7441e3dd4077d6f Reviewed-on: https://go-review.googlesource.com/c/go/+/287072 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/typexpr.go')
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index 9ab84b594b..b758c0f358 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -56,12 +56,12 @@ func (check *Checker) ident(x *operand, e *syntax.Name, def *Named, wantType boo
}
assert(typ != nil)
- // The object may be dot-imported: If so, remove its package from
- // the map of unused dot imports for the respective file scope.
+ // The object may have been dot-imported.
+ // If so, mark the respective package as used.
// (This code is only needed for dot-imports. Without them,
// we only have to mark variables, see *Var case below).
- if pkg := obj.Pkg(); pkg != check.pkg && pkg != nil {
- delete(check.unusedDotImports[scope], pkg)
+ if pkgName := check.dotImportMap[dotImportKey{scope, obj}]; pkgName != nil {
+ pkgName.used = true
}
switch obj := obj.(type) {