compiler: only import variable into . if same package

If we dot-import a package, we should only add an imported variable to
the package bindings if the variable is in the package being imported.
A test case for this is the 1.13 os package, in which ErrClosed and
friends are defined both locally and in the imported internal/oserror package.

Change-Id: I43e1a08cafa5e6136a82194d32f3deb23bec7d69
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192718
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/go/import.cc b/go/import.cc
index 64c1ef2..bbc8d7d 100644
--- a/go/import.cc
+++ b/go/import.cc
@@ -777,7 +777,7 @@
 			       this->location_);
   Named_object* no;
   no = vpkg->add_variable(name, var);
-  if (this->add_to_globals_)
+  if (this->add_to_globals_ && vpkg == this->package_)
     this->gogo_->add_dot_import_object(no);
 }