]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgo/go/go/types/errors.go
libgo: update to Go1.14beta1
[thirdparty/gcc.git] / libgo / go / go / types / errors.go
index 68c96c037eacf6f3cf22344df9e2dbef3221746d..91b077163c403f1080a09e69ac3c8e5c3f817595 100644 (file)
@@ -10,7 +10,7 @@ import (
        "fmt"
        "go/ast"
        "go/token"
-       "path"
+       "strconv"
        "strings"
 )
 
@@ -25,8 +25,13 @@ func unreachable() {
 }
 
 func (check *Checker) qualifier(pkg *Package) string {
+       // Qualify the package unless it's the package being type-checked.
        if pkg != check.pkg {
-               return path.Base(pkg.path) // avoid excessively long path names in error messages
+               // If the same package name was used by multiple packages, display the full path.
+               if check.pkgCnt[pkg.name] > 1 {
+                       return strconv.Quote(pkg.path)
+               }
+               return pkg.name
        }
        return ""
 }
@@ -82,6 +87,10 @@ func (check *Checker) err(pos token.Pos, msg string, soft bool) {
                check.firstErr = err
        }
 
+       if trace {
+               check.trace(pos, "ERROR: %s", msg)
+       }
+
        f := check.conf.Error
        if f == nil {
                panic(bailout{}) // report only first error