@@ -66,11 +66,12 @@ type typeCheckBatch struct {
66
66
handleMu sync.Mutex
67
67
_handles map [PackageID ]* packageHandle
68
68
69
- parseCache * parseCache
70
- fset * token.FileSet // describes all parsed or imported files
71
- cpulimit chan unit // concurrency limiter for CPU-bound operations
72
- syntaxPackages * futureCache [PackageID , * Package ] // transient cache of in-progress syntax futures
73
- importPackages * futureCache [PackageID , * types.Package ] // persistent cache of imports
69
+ parseCache * parseCache
70
+ fset * token.FileSet // describes all parsed or imported files
71
+ cpulimit chan unit // concurrency limiter for CPU-bound operations
72
+ syntaxPackages * futureCache [PackageID , * Package ] // transient cache of in-progress syntax futures
73
+ importPackages * futureCache [PackageID , * types.Package ] // persistent cache of imports
74
+ gopackagesdriver bool // for bug reporting: were packages loaded with a driver?
74
75
}
75
76
76
77
// addHandles is called by each goroutine joining the type check batch, to
@@ -237,7 +238,7 @@ func (s *Snapshot) acquireTypeChecking() (*typeCheckBatch, func()) {
237
238
238
239
if s .batch == nil {
239
240
assert (s .batchRef == 0 , "miscounted type checking" )
240
- s .batch = newTypeCheckBatch (s .view .parseCache )
241
+ s .batch = newTypeCheckBatch (s .view .parseCache , s . view . typ == GoPackagesDriverView )
241
242
}
242
243
s .batchRef ++
243
244
@@ -256,14 +257,15 @@ func (s *Snapshot) acquireTypeChecking() (*typeCheckBatch, func()) {
256
257
// shared parseCache.
257
258
//
258
259
// If a non-nil importGraph is provided, imports in this graph will be reused.
259
- func newTypeCheckBatch (parseCache * parseCache ) * typeCheckBatch {
260
+ func newTypeCheckBatch (parseCache * parseCache , gopackagesdriver bool ) * typeCheckBatch {
260
261
return & typeCheckBatch {
261
- _handles : make (map [PackageID ]* packageHandle ),
262
- parseCache : parseCache ,
263
- fset : fileSetWithBase (reservedForParsing ),
264
- cpulimit : make (chan unit , runtime .GOMAXPROCS (0 )),
265
- syntaxPackages : newFutureCache [PackageID , * Package ](false ), // don't persist syntax packages
266
- importPackages : newFutureCache [PackageID , * types.Package ](true ), // ...but DO persist imports
262
+ _handles : make (map [PackageID ]* packageHandle ),
263
+ parseCache : parseCache ,
264
+ fset : fileSetWithBase (reservedForParsing ),
265
+ cpulimit : make (chan unit , runtime .GOMAXPROCS (0 )),
266
+ syntaxPackages : newFutureCache [PackageID , * Package ](false ), // don't persist syntax packages
267
+ importPackages : newFutureCache [PackageID , * types.Package ](true ), // ...but DO persist imports
268
+ gopackagesdriver : gopackagesdriver ,
267
269
}
268
270
}
269
271
@@ -479,8 +481,14 @@ func (b *typeCheckBatch) importPackage(ctx context.Context, mp *metadata.Package
479
481
// manifest in the export data of mp.PkgPath is
480
482
// inconsistent with mp.Name. Or perhaps there
481
483
// are duplicate PkgPath items in the manifest?
482
- return bug .Errorf ("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904)" ,
483
- pkg .Name (), item .Name , id , item .Path )
484
+ if b .gopackagesdriver {
485
+ return bug .Errorf ("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904) (using GOPACKAGESDRIVER)" ,
486
+ pkg .Name (), item .Name , id , item .Path )
487
+ } else {
488
+ return bug .Errorf ("internal error: package name is %q, want %q (id=%q, path=%q) (see issue #60904)" ,
489
+ pkg .Name (), item .Name , id , item .Path )
490
+
491
+ }
484
492
}
485
493
} else {
486
494
id = importLookup (PackagePath (item .Path ))
0 commit comments