go/internal/gcimporter: fix reexporting compiler data
The current versions of the indexed export format encode constant
values based on their type. However, IExportData was encoding
constants values based on their own kind instead. While cmd/compile
internally keeps these matched, go/types does not guarantee the
same (see also golang/go#43891).
This CL fixes this issue, and also extends testing to check reading in
the compiler's export data and that imported packages can be exported
again.
Change-Id: I08f1845f371edd87773df0ef85bcd4e28f5db2f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/292351
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/go/internal/gcimporter/bexport_test.go b/go/internal/gcimporter/bexport_test.go
index de7b921..73585a6 100644
--- a/go/internal/gcimporter/bexport_test.go
+++ b/go/internal/gcimporter/bexport_test.go
@@ -12,6 +12,7 @@
"go/parser"
"go/token"
"go/types"
+ "path/filepath"
"reflect"
"runtime"
"strings"
@@ -117,7 +118,8 @@
func fileLine(fset *token.FileSet, obj types.Object) string {
posn := fset.Position(obj.Pos())
- return fmt.Sprintf("%s:%d", posn.Filename, posn.Line)
+ filename := filepath.Clean(strings.ReplaceAll(posn.Filename, "$GOROOT", build.Default.GOROOT))
+ return fmt.Sprintf("%s:%d", filename, posn.Line)
}
// equalObj reports how x and y differ. They are assumed to belong to