]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typealias] go/types: clarified doc string
authorRobert Griesemer <gri@golang.org>
Tue, 17 Jan 2017 19:40:04 +0000 (11:40 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 17 Jan 2017 20:31:39 +0000 (20:31 +0000)
Also: removed internal TODO and added better comment

Fixes #18644.

Change-Id: I3e3763d3afdad6937173cdd32fc661618fb60820
Reviewed-on: https://go-review.googlesource.com/35245
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/go/types/object.go

index 1668ba396bea79c0d6300528b3f3f5dd6be14b28..3c44348696600191e46d0d7e22919dd4ca99f0f1 100644 (file)
@@ -25,7 +25,7 @@ type Object interface {
        Name() string   // package local object name
        Type() Type     // object type
        Exported() bool // reports whether the name starts with a capital letter
-       Id() string     // object id (see Id below)
+       Id() string     // object name if exported, qualified name if not exported (see func Id)
 
        // String returns a human-readable string of the object.
        String() string
@@ -64,15 +64,10 @@ func Id(pkg *Package, name string) string {
        // inside a package and outside a package - which breaks some
        // tests)
        path := "_"
-       // TODO(gri): shouldn't !ast.IsExported(name) => pkg != nil be an precondition?
-       // if pkg == nil {
-       //      panic("nil package in lookup of unexported name")
-       // }
-       if pkg != nil {
+       // pkg is nil for objects in Universe scope and possibly types
+       // introduced via Eval (see also comment in object.sameId)
+       if pkg != nil && pkg.path != "" {
                path = pkg.path
-               if path == "" {
-                       path = "_"
-               }
        }
        return path + "." + name
 }