@@ -1237,7 +1237,7 @@ func (ld *loader) loadFromExportData(lpkg *loaderPackage) (*types.Package, error
1237
1237
return nil , fmt .Errorf ("reading %s: %v" , lpkg .ExportFile , err )
1238
1238
}
1239
1239
if viewLen != len (view ) {
1240
- log .Fatalf ( "Unexpected package creation during export data loading" )
1240
+ log .Panicf ( "golang.org/x/tools/go/packages: unexpected new packages during load of %s" , lpkg . PkgPath )
1241
1241
}
1242
1242
1243
1243
lpkg .Types = tpkg
@@ -1248,17 +1248,8 @@ func (ld *loader) loadFromExportData(lpkg *loaderPackage) (*types.Package, error
1248
1248
1249
1249
// impliedLoadMode returns loadMode with its dependencies.
1250
1250
func impliedLoadMode (loadMode LoadMode ) LoadMode {
1251
- if loadMode & NeedTypesInfo != 0 && loadMode & NeedImports == 0 {
1252
- // If NeedTypesInfo, go/packages needs to do typechecking itself so it can
1253
- // associate type info with the AST. To do so, we need the export data
1254
- // for dependencies, which means we need to ask for the direct dependencies.
1255
- // NeedImports is used to ask for the direct dependencies.
1256
- loadMode |= NeedImports
1257
- }
1258
-
1259
- if loadMode & NeedDeps != 0 && loadMode & NeedImports == 0 {
1260
- // With NeedDeps we need to load at least direct dependencies.
1261
- // NeedImports is used to ask for the direct dependencies.
1251
+ if loadMode & (NeedDeps | NeedTypes | NeedTypesInfo ) != 0 {
1252
+ // All these things require knowing the import graph.
1262
1253
loadMode |= NeedImports
1263
1254
}
1264
1255
0 commit comments