diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index 2272ac0645..d48dcbffc3 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -540,6 +540,10 @@ func (check *Checker) interfaceType(iface *Interface, ityp *ast.InterfaceType, d } iface.embeddeds = append(iface.embeddeds, named) // collect embedded methods + if debug && embed.allMethods == nil { + check.dump("%s: incomplete embedded interface %s", pos, named) + unreachable() + } for _, m := range embed.allMethods { if check.declareInSet(&mset, pos, m) { iface.allMethods = append(iface.allMethods, m) @@ -579,7 +583,11 @@ func (check *Checker) interfaceType(iface *Interface, ityp *ast.InterfaceType, d // claim source order in the future. Revisit. sort.Sort(byUniqueTypeName(iface.embeddeds)) - sort.Sort(byUniqueMethodName(iface.allMethods)) + if iface.allMethods == nil { + iface.allMethods = make([]*Func, 0) // mark interface as complete + } else { + sort.Sort(byUniqueMethodName(iface.allMethods)) + } } // byUniqueTypeName named type lists can be sorted by their unique type names.