apidiff: require exported old types to match same-named type in new

Previously, correspondence was sometimes established between completely
unrelated types. This CL tightens the requirements for two exported types
to correspond: the only possibilities are that they have the same name,
or the new type is an alias for the old.

Examples:
	old: type T int    new: type T int
	same name: the T's correspond

	old: type T int    new: type T = U; type U int
	different name, but T is an alias for U.

This might seem to exclude another case:

	old: type T = U; type U int		new: type U int

It seems that T should correspond to U even though the above conditions
aren't met. But in fact U corresponds to U here, not T. Correspondence
is 1:1; we pick the closest match.

This may seem unrelated to the new test case, which reports that two
struct fields are incompatible instead of just one. But the reason that
the old code didn't report one of the fields is that it established a
correspondence between the fields' types, despite their being completely
unrelated.

Fixes golang/go#81523.

Change-Id: I8ab02d13acb606d4ea26fc73fa4d7ee5042d18d7
Reviewed-on: https://go-review.googlesource.com/c/exp/+/836046
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
3 files changed
tree: 80536e9e93606aac28aea47783a16d9d1c2d98ed
  1. apidiff/
  2. cmd/
  3. constraints/
  4. ebnf/
  5. ebnflint/
  6. errors/
  7. eval/
  8. event/
  9. inotify/
  10. io/
  11. jsonrpc2/
  12. maps/
  13. mmap/
  14. rand/
  15. shiny/
  16. shootout/
  17. slices/
  18. slog/
  19. stats/
  20. trace/
  21. typeparams/
  22. utf8string/
  23. .gitattributes
  24. .gitignore
  25. codereview.cfg
  26. CONTRIBUTING.md
  27. go.mod
  28. go.sum
  29. LICENSE
  30. PATENTS
  31. README.md
README.md

exp

PkgGoDev

This subrepository holds experimental and deprecated (in the old directory) packages.

The idea for this subrepository originated as the pkg/exp directory of the main repository, but its presence there made it unavailable to users of the binary downloads of the Go installation. The subrepository has therefore been created to make it possible to go get these packages.

Warning: Packages here are experimental and unreliable. Some may one day be promoted to the main repository or other subrepository, or they may be modified arbitrarily or even disappear altogether.

In short, code in this subrepository is not subject to the Go 1 compatibility promise. (No subrepo is, but the promise is even more likely to be violated by go.exp than the others.)

Caveat emptor.