[dev.regabi] cmd/compile: simplify CaptureVars
[dev.regabi] cmd/compile: simplify CaptureVars

CaptureVars is responsible for deciding whether free variables should
be captured by value or by reference, but currently it also makes up
for some of the short-comings of the frontend symbol resolution /
type-checking algorithms. These are really separate responsibilities,
so move the latter into type-checking where it fits better.

Passes toolstash -cmp.

Change-Id: Iffbd53e83846a9ca9dfb54b597450b8543252850
Reviewed-on: https://go-review.googlesource.com/c/go/+/281534
Trust: Matthew Dempsky <e56ac2c500064424afac424d4b5e53bd0570a731@google.com>
Run-TryBot: Matthew Dempsky <e56ac2c500064424afac424d4b5e53bd0570a731@google.com>
TryBot-Result: Go Bot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Cuong Manh Le <54b4457f1dff6823379654eb5867596497ba782f@gmail.com>

cloudflare/go,golang/go,CAFxX/go,cloudflare/go,golang/go,CAFxX/go,nawawi/go,CAFxX/go,nawawi/go,cloudflare/go,nawawi/go,cloudflare/go,golang/go,nawawi/go,CAFxX/go,nawawi/go,CAFxX/go,cloudflare/go,golang/go,nawawi/go,golang/go,CAFxX/go,golang/go,CAFxX/go,golang/go,golang/go,CAFxX/go,cloudflare/go,cloudflare/go,nawawi/go,nawawi/go,cloudflare/go