]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: don't lose position info of interface embeddings
authorRobert Griesemer <gri@golang.org>
Wed, 10 Jan 2024 23:49:33 +0000 (15:49 -0800)
committerRobert Griesemer <gri@google.com>
Thu, 11 Jan 2024 17:47:50 +0000 (17:47 +0000)
commit25c5f6f15988f1abb9738bfdfd10331afefd8ec1
treeaed6e97c7f12b53fdd5e6050701c67acffb2c4ce
parentd1674cb4c6531df6573bc3be136b302d2b362c56
go/types, types2: don't lose position info of interface embeddings

Accurate position information for embedded types in interfaces is
crucial to identify the corresponding source file, and with that
the Go language version associated with that file. (The position
information is also important for proper error messages.)

Before this CL, the position information for embedded types was
discarded after type set computation, in the assumption that it
was not needed anymore. However, substitutions that update the
interface may lead to repeated type set computations which then
won't have the correct position information.

This CL does preserve the position information for embedded
types until the end of type checking (cleanup phase), and also
copy the position information during a substitution of the
interface.

The respective bug (#64759) doesn't seem to appear in 1.22 (most
likely because it's hidden by some of the changes made with respect
to the file version logic), but the existing code is still wrong.
The backport of this code to 1.21 and 1.20 fixes the issue in those
releases.

For #64759.

Change-Id: I80f4004c9d79cb02eac6739c324c477706615102
Reviewed-on: https://go-review.googlesource.com/c/go/+/555296
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/issues_test.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/typeset.go
src/go/types/issues_test.go
src/go/types/subst.go
src/go/types/typeset.go