]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.21] go/types, types2: don't lose position info of interface embed...
authorRobert Griesemer <gri@golang.org>
Wed, 10 Jan 2024 23:49:33 +0000 (15:49 -0800)
committerCherry Mui <cherryyz@google.com>
Thu, 25 Jan 2024 17:49:05 +0000 (17:49 +0000)
commit00f974eb1f1ecbdf0d16667cd82a5aec16216d7f
treecb0513dc12783c47ba699553dab64c468196c5cc
parent2f91c16e68b8c82e4ca2e422bf9a520ec46f817c
[release-branch.go1.21] 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.
Fixes #65053.

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>
Reviewed-on: https://go-review.googlesource.com/c/go/+/555415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.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