Skip to content

Commit 85554d6

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/lsp/cache: add debugging assertion for golang/go#60904
Updates golang/go#60904 Change-Id: Ia9f259716732705060a0d3675cd701c6c68a215f Reviewed-on: https://go-review.googlesource.com/c/tools/+/504695 gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 9960b69 commit 85554d6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

gopls/internal/lsp/cache/check.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,25 @@ func (b *typeCheckBatch) importPackage(ctx context.Context, m *source.Metadata,
541541
thisPackage := types.NewPackage(string(m.PkgPath), string(m.Name))
542542
getPackages := func(items []gcimporter.GetPackagesItem) error {
543543
for i, item := range items {
544+
var id PackageID
545+
var pkg *types.Package
544546
if item.Path == string(m.PkgPath) {
545-
items[i].Pkg = thisPackage
547+
id = m.ID
548+
pkg = thisPackage
546549
} else {
547-
pkg, err := b.getImportPackage(ctx, impMap[item.Path])
550+
id = impMap[item.Path]
551+
var err error
552+
pkg, err = b.getImportPackage(ctx, id)
548553
if err != nil {
549554
return err
550555
}
551-
items[i].Pkg = pkg
556+
}
557+
items[i].Pkg = pkg
558+
559+
// debugging issue #60904
560+
if pkg.Name() != item.Name {
561+
return bug.Errorf("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904)",
562+
pkg.Name(), item.Name, id, item.Path)
552563
}
553564
}
554565
return nil

0 commit comments

Comments
 (0)