diff options
author | Alan Donovan <adonovan@google.com> | 2024-04-05 17:34:16 -0400 |
---|---|---|
committer | Alan Donovan <adonovan@google.com> | 2024-04-08 16:36:08 +0000 |
commit | e8f5c04c1bcbc1fe33ddb7ab898ec393d3b2ad77 (patch) | |
tree | f644035555776fa247c6c34105b04b9b026a7fb1 /src/go | |
parent | da732dd1c0304819ae107754206eb9da7d282469 (diff) | |
download | go-e8f5c04c1bcbc1fe33ddb7ab898ec393d3b2ad77.tar.gz go-e8f5c04c1bcbc1fe33ddb7ab898ec393d3b2ad77.zip |
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>
Diffstat (limited to 'src/go')
-rw-r--r-- | src/go/types/api_predicates.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/go/types/api_predicates.go b/src/go/types/api_predicates.go index 8462baae45..4a6b3fe9ca 100644 --- a/src/go/types/api_predicates.go +++ b/src/go/types/api_predicates.go @@ -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) |