package types
-import "sort"
-
func isNamed(typ Type) bool {
if _, ok := typ.(*Basic); ok {
return ok
p = p.prev
}
if debug {
- assert(sort.IsSorted(byUniqueMethodName(a)))
- assert(sort.IsSorted(byUniqueMethodName(b)))
+ assertSortedMethods(a)
+ assertSortedMethods(b)
}
for i, f := range a {
g := b[i]
package types
-import "sort"
-
// A Type represents a type of Go.
// All types implement the Type interface.
type Type interface {
}
// sort for API stability
- sort.Sort(byUniqueMethodName(methods))
- sort.Stable(byUniqueTypeName(embeddeds))
+ sortMethods(methods)
+ sortTypes(embeddeds)
typ.methods = methods
typ.embeddeds = embeddeds
}
if methods != nil {
- sort.Sort(byUniqueMethodName(methods))
+ sortMethods(methods)
t.allMethods = methods
}
}
// sort for API stability
- sort.Sort(byUniqueMethodName(ityp.methods))
- sort.Stable(byUniqueTypeName(ityp.embeddeds))
+ sortMethods(ityp.methods)
+ sortTypes(ityp.embeddeds)
check.later(func() { check.completeInterface(ityp) })
}
}
}
+func sortTypes(list []Type) {
+ sort.Stable(byUniqueTypeName(list))
+}
+
// byUniqueTypeName named type lists can be sorted by their unique type names.
type byUniqueTypeName []Type
return ""
}
+func sortMethods(list []*Func) {
+ sort.Sort(byUniqueMethodName(list))
+}
+
+func assertSortedMethods(list []*Func) {
+ if !debug {
+ panic("internal error: assertSortedMethods called outside debug mode")
+ }
+ if !sort.IsSorted(byUniqueMethodName(list)) {
+ panic("internal error: methods not sorted")
+ }
+}
+
// byUniqueMethodName method lists can be sorted by their unique method names.
type byUniqueMethodName []*Func