]> Cypherpunks repositories - gostls13.git/commitdiff
go/internal/srcimporter: return (possibly incomplete) package in case of error
authorRobert Griesemer <gri@golang.org>
Fri, 3 Mar 2017 21:07:54 +0000 (13:07 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 6 Mar 2017 18:51:17 +0000 (18:51 +0000)
For #16088.

Change-Id: I0ff480e95ef5af375be2ccc655f8b233a7bcd39d
Reviewed-on: https://go-review.googlesource.com/37755
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/internal/srcimporter/srcimporter.go

index 45fddb9feeef2ca2d23cb78e6a18d95d743f2801..f259493fc7f2a547f6cd88246acbdfdb0eb2530a 100644 (file)
@@ -93,10 +93,11 @@ func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*type
                        return nil, fmt.Errorf("import cycle through package %q", bp.ImportPath)
                }
                if !pkg.Complete() {
-                       // package exists but is not complete - we cannot handle this
+                       // Package exists but is not complete - we cannot handle this
                        // at the moment since the source importer replaces the package
-                       // wholesale rather than augmenting it (see #19337 for details)
-                       return nil, fmt.Errorf("reimported partially imported package %q", bp.ImportPath)
+                       // wholesale rather than augmenting it (see #19337 for details).
+                       // Return incomplete package with error (see #16088).
+                       return pkg, fmt.Errorf("reimported partially imported package %q", bp.ImportPath)
                }
                return pkg, nil
        }
@@ -135,7 +136,8 @@ func (p *Importer) ImportFrom(path, srcDir string, mode types.ImportMode) (*type
        }
        pkg, err = conf.Check(bp.ImportPath, p.fset, files, nil)
        if err != nil {
-               return nil, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err)
+               // return (possibly nil or incomplete) package with error (see #16088)
+               return pkg, fmt.Errorf("type-checking package %q failed (%v)", bp.ImportPath, err)
        }
 
        p.packages[bp.ImportPath] = pkg