[dev.typeparams] cmd/compile: fail early on unexpected types2.Invalid
[dev.typeparams] cmd/compile: fail early on unexpected types2.Invalid

In unified IR, fail right away if we find a types2.Invalid while
writing out the package. This provides a clearer error message for
https://github.com/golang/go/issues/25838#issuecomment-448746670.

Updates #25838.

Change-Id: I6902fdd891fc31bbb832b6fdba00eca301282409
Reviewed-on: https://go-review.googlesource.com/c/go/+/338973
Trust: Matthew Dempsky <e56ac2c500064424afac424d4b5e53bd0570a731@google.com>
Run-TryBot: Matthew Dempsky <e56ac2c500064424afac424d4b5e53bd0570a731@google.com>
TryBot-Result: Go Bot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Robert Griesemer <a6752097faebf1f02d80107d77a9be009089afe3@golang.org>

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