compiler: always sort interface parse methods
authorIan Lance Taylor <iant@golang.org>
Thu, 12 May 2022 02:23:01 +0000 (19:23 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 13 May 2022 22:21:12 +0000 (15:21 -0700)
commitdd7813f05df50d2ad8e0dc34503f2dff0b521d89
tree737f1de3db3655c45a6997804f567e91fd57ba8b
parentd75d4293dcc029a7b00f902d9b03416c9439af4d
compiler: always sort interface parse methods

The exporter relies on sorting interface parse methods.  It would sort
them as it encountered interface types.  However, when an interface
type is an element of a struct or array type, the exporter might
encounter that interface type before sorting the parse methods.  If it
then encountered an identical interface type again, it could get
confused about whether the two types are identical or not.

Fix the problem by always sorting the parse methods in the
finalize_methods pass.

Also firm up the export type sorting to make sure we never have this
kind of confusion again.  Doing this revealed that we need to be more
careful about sorting in order to handle aliases correctly.

Also fix the interface type hash computation to use the right hash
value when looking at parse methods rather than all methods.

The test case for this is https://go.dev/cl/405759.

Fixes golang/go#52841

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405556
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/export.cc
gcc/go/gofrontend/types.cc
gcc/go/gofrontend/types.h