1
0
mirror of https://github.com/golang/go synced 2024-11-15 03:00:36 -07:00

go/types: Identical: document the need for consistent symbols

Fixes golang/go#66690
Updates golang/go#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>
This commit is contained in:
Alan Donovan 2024-04-05 17:34:16 -04:00
parent da732dd1c0
commit e8f5c04c1b
2 changed files with 24 additions and 0 deletions

View File

@ -70,6 +70,18 @@ func Satisfies(V Type, T *Interface) bool {
// Identical reports whether x and y are identical types.
// Receivers of [Signature] types are ignored.
//
// Predicates such as [Identical], [Implements], and
// [Satisfies] assume that both operands belong to a
// consistent collection of symbols ([Object] values).
// For example, two [Named] types can be identical only if their
// [Named.Obj] methods return the same [TypeName] symbol.
// A collection of symbols is consistent if, for each logical
// package whose path is P, the creation of those symbols
// involved at most one call to [NewPackage](P, ...).
// To ensure consistency, use a single [Importer] for
// all loaded packages and their dependencies.
// For more information, see https://github.com/golang/go/issues/57497.
func Identical(x, y Type) bool {
var c comparer
return c.identical(x, y, nil)

View File

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