Skip to content

Commit

Permalink
gopls/internal/lsp/cache: add debugging assertion for #60904
Browse files Browse the repository at this point in the history
Updates #60904

Change-Id: Ia9f259716732705060a0d3675cd701c6c68a215f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/504695
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
  • Loading branch information
adonovan authored and gopherbot committed Jun 20, 2023
1 parent 9960b69 commit 85554d6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions gopls/internal/lsp/cache/check.go
Expand Up @@ -541,14 +541,25 @@ func (b *typeCheckBatch) importPackage(ctx context.Context, m *source.Metadata,
thisPackage := types.NewPackage(string(m.PkgPath), string(m.Name))
getPackages := func(items []gcimporter.GetPackagesItem) error {
for i, item := range items {
var id PackageID
var pkg *types.Package
if item.Path == string(m.PkgPath) {
items[i].Pkg = thisPackage
id = m.ID
pkg = thisPackage
} else {
pkg, err := b.getImportPackage(ctx, impMap[item.Path])
id = impMap[item.Path]
var err error
pkg, err = b.getImportPackage(ctx, id)
if err != nil {
return err
}
items[i].Pkg = pkg
}
items[i].Pkg = pkg

// debugging issue #60904
if pkg.Name() != item.Name {
return bug.Errorf("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904)",
pkg.Name(), item.Name, id, item.Path)
}
}
return nil
Expand Down

0 comments on commit 85554d6

Please sign in to comment.