Skip to content

Commit e8f5c04

Browse files
committed
go/types: Identical: document the need for consistent symbols
Fixes #66690 Updates #57497 Change-Id: I3d8f48d6b9baae8d5518eefeff59c83b12728cf5 Reviewed-on: https://go-review.googlesource.com/c/go/+/577015 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
1 parent da732dd commit e8f5c04

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/cmd/compile/internal/types2/api_predicates.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ func Satisfies(V Type, T *Interface) bool {
7070

7171
// Identical reports whether x and y are identical types.
7272
// Receivers of [Signature] types are ignored.
73+
//
74+
// Predicates such as [Identical], [Implements], and
75+
// [Satisfies] assume that both operands belong to a
76+
// consistent collection of symbols ([Object] values).
77+
// For example, two [Named] types can be identical only if their
78+
// [Named.Obj] methods return the same [TypeName] symbol.
79+
// A collection of symbols is consistent if, for each logical
80+
// package whose path is P, the creation of those symbols
81+
// involved at most one call to [NewPackage](P, ...).
82+
// To ensure consistency, use a single [Importer] for
83+
// all loaded packages and their dependencies.
84+
// For more information, see https://github.com/golang/go/issues/57497.
7385
func Identical(x, y Type) bool {
7486
var c comparer
7587
return c.identical(x, y, nil)

src/go/types/api_predicates.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)