@@ -75,7 +75,7 @@ const (
75
75
76
76
// Deprecated: LoadImports exists for historical compatibility
77
77
// and should not be used. Please directly specify the needed fields using the Need values.
78
- LoadImports = LoadFiles | NeedImports | NeedDeps
78
+ LoadImports = LoadFiles | NeedImports
79
79
80
80
// Deprecated: LoadTypes exists for historical compatibility
81
81
// and should not be used. Please directly specify the needed fields using the Need values.
@@ -87,7 +87,7 @@ const (
87
87
88
88
// Deprecated: LoadAllSyntax exists for historical compatibility
89
89
// and should not be used. Please directly specify the needed fields using the Need values.
90
- LoadAllSyntax = LoadSyntax
90
+ LoadAllSyntax = LoadSyntax | NeedDeps
91
91
)
92
92
93
93
// A Config specifies details about how packages should be loaded.
@@ -479,8 +479,8 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
479
479
}
480
480
lpkg := & loaderPackage {
481
481
Package : pkg ,
482
- needtypes : (ld .Mode & (NeedTypes | NeedTypesInfo ) != 0 && rootIndex < 0 ) || rootIndex >= 0 ,
483
- needsrc : (ld .Mode & (NeedSyntax | NeedTypesInfo ) != 0 && rootIndex < 0 ) || rootIndex >= 0 ||
482
+ needtypes : (ld .Mode & (NeedTypes | NeedTypesInfo ) != 0 && ld . Mode & NeedDeps != 0 && rootIndex < 0 ) || rootIndex >= 0 ,
483
+ needsrc : (ld .Mode & (NeedSyntax | NeedTypesInfo ) != 0 && ld . Mode & NeedDeps != 0 && rootIndex < 0 ) || rootIndex >= 0 ||
484
484
len (ld .Overlay ) > 0 || // Overlays can invalidate export data. TODO(matloob): make this check fine-grained based on dependencies on overlaid files
485
485
pkg .ExportFile == "" && pkg .PkgPath != "unsafe" ,
486
486
}
@@ -528,8 +528,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
528
528
stack = append (stack , lpkg ) // push
529
529
stubs := lpkg .Imports // the structure form has only stubs with the ID in the Imports
530
530
// If NeedImports isn't set, the imports fields will all be zeroed out.
531
- // If NeedDeps isn't also set we want to keep the stubs.
532
- if ld .Mode & NeedImports != 0 && ld .Mode & NeedDeps != 0 {
531
+ if ld .Mode & NeedImports != 0 {
533
532
lpkg .Imports = make (map [string ]* Package , len (stubs ))
534
533
for importPath , ipkg := range stubs {
535
534
var importErr error
@@ -577,7 +576,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
577
576
visit (lpkg )
578
577
}
579
578
}
580
- if ld .Mode & NeedDeps != 0 { // TODO(matloob): This is only the case if NeedTypes is also set, right?
579
+ if ld .Mode & NeedImports != 0 && ld . Mode & NeedTypes != 0 {
581
580
for _ , lpkg := range srcPkgs {
582
581
// Complete type information is required for the
583
582
// immediate dependencies of each source package.
@@ -602,7 +601,6 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
602
601
}
603
602
604
603
result := make ([]* Package , len (initial ))
605
- importPlaceholders := make (map [string ]* Package )
606
604
for i , lpkg := range initial {
607
605
result [i ] = lpkg .Package
608
606
}
@@ -639,16 +637,6 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
639
637
if ld .Mode & NeedTypesSizes == 0 {
640
638
ld .pkgs [i ].TypesSizes = nil
641
639
}
642
- if ld .Mode & NeedDeps == 0 {
643
- for j , pkg := range ld .pkgs [i ].Imports {
644
- ph , ok := importPlaceholders [pkg .ID ]
645
- if ! ok {
646
- ph = & Package {ID : pkg .ID }
647
- importPlaceholders [pkg .ID ] = ph
648
- }
649
- ld .pkgs [i ].Imports [j ] = ph
650
- }
651
- }
652
640
}
653
641
return result , nil
654
642
}
@@ -670,7 +658,6 @@ func (ld *loader) loadRecursive(lpkg *loaderPackage) {
670
658
}(imp )
671
659
}
672
660
wg .Wait ()
673
-
674
661
ld .loadPackage (lpkg )
675
662
})
676
663
}
@@ -797,7 +784,7 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
797
784
if ipkg .Types != nil && ipkg .Types .Complete () {
798
785
return ipkg .Types , nil
799
786
}
800
- log .Fatalf ("internal error: nil Pkg importing %q from %q" , path , lpkg )
787
+ log .Fatalf ("internal error: package %q without types was imported from %q" , path , lpkg )
801
788
panic ("unreachable" )
802
789
})
803
790
@@ -808,7 +795,7 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
808
795
// Type-check bodies of functions only in non-initial packages.
809
796
// Example: for import graph A->B->C and initial packages {A,C},
810
797
// we can ignore function bodies in B.
811
- IgnoreFuncBodies : ( ld .Mode & ( NeedDeps | NeedTypesInfo ) == 0 ) && ! lpkg .initial ,
798
+ IgnoreFuncBodies : ld .Mode & NeedDeps == 0 && ! lpkg .initial ,
812
799
813
800
Error : appendError ,
814
801
Sizes : ld .sizes ,
@@ -1071,5 +1058,5 @@ func (ld *loader) loadFromExportData(lpkg *loaderPackage) (*types.Package, error
1071
1058
}
1072
1059
1073
1060
func usesExportData (cfg * Config ) bool {
1074
- return cfg .Mode & NeedExportsFile != 0 || cfg .Mode & NeedTypes != 0 && cfg .Mode & NeedTypesInfo == 0
1061
+ return cfg .Mode & NeedExportsFile != 0 || cfg .Mode & NeedTypes != 0 && cfg .Mode & NeedDeps == 0
1075
1062
}
0 commit comments