From 86d6865ab29d5ecbe3a7502471d17550a377a7ab Mon Sep 17 00:00:00 2001 From: Uriel Corfa Date: Thu, 13 Jul 2017 01:36:12 +0800 Subject: [PATCH] Fix: references to packages ignored by filterF were not created --- packagegraph.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packagegraph.go b/packagegraph.go index cbe96e7..5022e85 100644 --- a/packagegraph.go +++ b/packagegraph.go @@ -133,6 +133,7 @@ func (pg *PackageGraph) loadPackage(prog *loader.Program, loadpath string, pi *l if specialPkg := specialPackage(loadpath); specialPkg != nil { pkg = specialPkg } + // If we didn't find a hardcoded package, rely on versionF to // tell us what version this package should have. Otherwise // use the hardcoded Package's Version. @@ -147,13 +148,6 @@ func (pg *PackageGraph) loadPackage(prog *loader.Program, loadpath string, pi *l version = pkg.Version } - // Apply filterF to stop loading any package that doesn't pass - // the filter. Note that if a package was already present in - // the graph, filterF is not called. - if !pg.filterF(loadpath, version) { - return nil - } - // Find what corpus this package was loaded from. var corpus Corpus if len(pi.Files) > 0 { @@ -174,6 +168,13 @@ func (pg *PackageGraph) loadPackage(prog *loader.Program, loadpath string, pi *l pkg = newPackage(pi, prog.Fset, version, corpus) pg.Packages[loadpath] = pkg + // Apply filterF to stop loading any package that doesn't pass + // the filter. Note that if a package was already present in + // the graph, filterF is not called. + if !pg.filterF(loadpath, version) { + return pkg + } + // Iterate over all files in that package. for _, f := range pi.Files { // Iterate over all imports in that file