// satisfy returns the set of interface satisfaction constraints. func (r *Unexporter) satisfy() map[satisfy.Constraint]bool { if r.satisfyConstraints == nil { // Compute on demand: it's expensive. var f satisfy.Finder for _, info := range r.packages { f.Find(&info.Info, info.Files) } r.satisfyConstraints = f.Result } return r.satisfyConstraints }
func calculateConstraints(u *Unexporter) { constraints := make(map[satisfy.Constraint]map[*types.Package]bool) for _, info := range u.prog.Imported { var finder satisfy.Finder finder.Find(&info.Info, info.Files) for constraint := range finder.Result { if _, ok := constraints[constraint]; !ok { constraints[constraint] = make(map[*types.Package]bool) } constraints[constraint][info.Pkg] = true } } u.f = constraints }
// findAssignments returns the set of types to or from which type T is // assigned in the program syntax. func (r *renamer) findAssignments(T types.Type) map[types.Type]bool { if r.satisfyConstraints == nil { // Compute on demand: it's expensive. var f satisfy.Finder for _, info := range r.packages { f.Find(&info.Info, info.Files) } r.satisfyConstraints = f.Result } result := make(map[types.Type]bool) for key := range r.satisfyConstraints { // key = (lhs, rhs) where lhs is always an interface. if types.Identical(key.RHS, T) { result[key.LHS] = true } if isInterface(T) && types.Identical(key.LHS, T) { // must check both sides result[key.RHS] = true } } return result }