Repository navigation
Commit 186053a
committed
cmd/compile: record method indices before encoding a named type
CL 826105 added explicit method indices to unified export data (V5)
so that importers can restore a named type's source method order.
But the encoder only recorded a type's method indices after encoding
its underlying type, and encoding the underlying type can encode one
of the type's own generic methods first: if a field's type has a
method whose body calls the generic method, encoding that body
encodes the generic method object, which then looks up its index
before it was recorded and gets 0. Importers then sort it among the
type's first methods, so objectpath again attributes analysis facts
to the wrong methods (crashing staticcheck as in golang#81188).
Record the indices before encoding anything else.
This is a cherry-pick of upstream CL 847627, ported to Go 1.27: the
test uses cmd/compile/internal/importer and go list -export instead
of master's cmd/compile/internal/testimporter, which go1.27 lacks.
Updates golang#81188
Updates golang#82105
Change-Id: Icc8cfdd5620bb6d50b1c0b296f325c7d99ee9cc5
(cherry picked from https://go-review.googlesource.com/c/go/+/847627)1 parent 509d157 commit 186053a
2 files changed
Lines changed: 94 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
920 | 928 | | |
921 | 929 | | |
922 | 930 | | |
| |||
926 | 934 | | |
927 | 935 | | |
928 | 936 | | |
929 | | - | |
930 | 937 | | |
931 | 938 | | |
932 | 939 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments