cmd/compile/internal/types2: use a typeWriter to write types (cleanup)
Rather then passing through a buffer, qualified, and visited
list to each helper function, maintain state in a typeWriter
object and use methods on it. This cleans up this code quite
a bit.
Use a map ("seen") for cycle detection rather than a list.
Move printing of [ and ] for type lists into the typeList
method so that callers don't have to do it themselves.
Change-Id: I1346373e979cb90710fbc073953aa51e2f6581f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/345890
Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>