func (check *Checker) resolveOrder() []Object {
	var ifaces, others []Object
	for obj := range check.objMap {
		if ityp := check.interfaceFor(obj); ityp != nil {
			ifaces = append(ifaces, obj)
			for _, f := range ityp.Methods.List {
				if len(f.Names) == 0 {
					if ident, _ := f.Type.(*ast.Ident); ident != nil {
						embedded := check.pkg.scope.Lookup(ident.Name)
						if check.interfaceFor(embedded) != nil {
							check.objMap[obj].addDep(embedded)
						}
					}
				}
			}
		} else {
			others = append(others, obj)
		}
	}
	var order []Object
	sort.Sort(inSourceOrder(ifaces))
	if debug {
		for _, obj := range ifaces {
			assert(check.objMap[obj].mark == 0)
		}
	}
	for _, obj := range ifaces {
		check.appendInPostOrder(&order, obj)
	}
	sort.Sort(inSourceOrder(others))
	return append(order, others...)
}
resolveOrder computes the order in which package-level objects
must be type-checked.

Interface types appear first in the list, sorted topologically
by dependencies on embedded interfaces that are also declared
in this package, followed by all other objects sorted in source
order.

TODO(gri) Consider sorting all types by dependencies here, and
in the process check _and_ report type cycles. This may simplify
the full type-checking phase.
package types
import (
	"go/ast"
	"sort"
)