return obj
}
+// pathString returns a string of the form a->b-> ... ->g for an object path [a, b, ... g].
+func (check *Checker) pathString() string {
+ var s string
+ for i, p := range check.objPath {
+ if i > 0 {
+ s += "->"
+ }
+ s += p.Name()
+ }
+ return s
+}
+
// NewChecker returns a new Checker instance for a given package.
// Package files may be added incrementally via checker.Files.
func NewChecker(conf *Config, fset *token.FileSet, pkg *Package, info *Info) *Checker {
}
if trace {
- check.trace(obj.Pos(), "-- checking %s (path = %s)", obj, pathString(path))
+ check.trace(obj.Pos(), "-- checking %s (path = %s, objPath = %s)", obj, pathString(path), check.pathString())
check.indent++
defer func() {
check.indent--
// to the next. For instance, for "type p *p" the object path contains
// p followed by indir, indicating that there's an indirection *p.
// Indirections are used to break type cycles.
-var indir = new(TypeName)
+var indir = NewTypeName(token.NoPos, nil, "*", nil)
// typeCycle checks if the cycle starting with obj is valid and
// reports an error if it is not.
}
if trace {
- check.trace(iface.Pos(), "-- collect methods for %v (path = %s)", iface, pathString(path))
+ check.trace(iface.Pos(), "-- collect methods for %v (path = %s, objPath = %s)", iface, pathString(path), check.pathString())
check.indent++
defer func() {
check.indent--