diff --git a/src/go/types/check.go b/src/go/types/check.go index 7d58183911..eec33057de 100644 --- a/src/go/types/check.go +++ b/src/go/types/check.go @@ -269,6 +269,21 @@ func (check *Checker) checkFiles(files []*ast.File) (err error) { return } +// processDelayed processes all delayed actions pushed after top. +func (check *Checker) processDelayed(top int) { + // If each delayed action pushes a new action, the + // stack will continue to grow during this loop. + // However, it is only processing functions (which + // are processed in a delayed fashion) that may + // add more actions (such as nested functions), so + // this is a sufficiently bounded process. + for i := top; i < len(check.delayed); i++ { + check.delayed[i]() // may append to check.delayed + } + assert(top <= len(check.delayed)) // stack must not have shrunk + check.delayed = check.delayed[:top] +} + func (check *Checker) processFinals() { n := len(check.finals) for _, f := range check.finals { diff --git a/src/go/types/resolver.go b/src/go/types/resolver.go index 417e4e79aa..93de63b059 100644 --- a/src/go/types/resolver.go +++ b/src/go/types/resolver.go @@ -607,16 +607,6 @@ func (a inSourceOrder) Len() int { return len(a) } func (a inSourceOrder) Less(i, j int) bool { return a[i].order() < a[j].order() } func (a inSourceOrder) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -// processDelayed processes all delayed actions pushed after top. -func (check *Checker) processDelayed(top int) { - for len(check.delayed) > top { - i := len(check.delayed) - 1 - f := check.delayed[i] - check.delayed = check.delayed[:i] - f() // may append to check.delayed - } -} - // unusedImports checks for unused imports. func (check *Checker) unusedImports() { // if function bodies are not checked, packages' uses are likely missing - don't check