src/cmd/compile/internal/types2/context.go | 7 ++++--- src/cmd/compile/internal/types2/instantiate.go | 3 ++- src/go/types/context.go | 7 ++++--- src/go/types/instantiate.go | 3 ++- diff --git a/src/cmd/compile/internal/types2/context.go b/src/cmd/compile/internal/types2/context.go index 7abea6b654b34dd738a707c21c3cd11a3ee48669..2d790fe5dddbbf30aa025241daeadfb3a7c2c595 100644 --- a/src/cmd/compile/internal/types2/context.go +++ b/src/cmd/compile/internal/types2/context.go @@ -12,11 +12,12 @@ "strings" "sync" ) -// An Context is an opaque type checking context. It may be used to share +// A Context is an opaque type checking context. It may be used to share // identical type instances across type-checked packages or calls to -// Instantiate. +// Instantiate. Contexts are safe for concurrent use. // -// It is safe for concurrent use. +// The use of a shared context does not guarantee that identical instances are +// deduplicated in all cases. type Context struct { mu sync.Mutex typeMap map[string][]ctxtEntry // type hash -> instances entries diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index 9eced489dcf114a190838f93258faa1c7a8cd707..2dc82d852e0fa794d4e40fc620d7b8a29ed1b6b9 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -24,7 +24,8 @@ // If ctxt is non-nil, it may be used to de-duplicate the instance against // previous instances with the same identity. As a special case, generic // *Signature origin types are only considered identical if they are pointer // equivalent, so that instantiating distinct (but possibly identical) -// signatures will yield different instances. +// signatures will yield different instances. The use of a shared context does +// not guarantee that identical instances are deduplicated in all cases. // // If validate is set, Instantiate verifies that the number of type arguments // and parameters match, and that the type arguments satisfy their diff --git a/src/go/types/context.go b/src/go/types/context.go index ff4bf89f3cb0076abca2a199c2288bee980276a9..692b3a66828a9c593432c1a8a4ad92fc9be0f626 100644 --- a/src/go/types/context.go +++ b/src/go/types/context.go @@ -12,11 +12,12 @@ "strings" "sync" ) -// An Context is an opaque type checking context. It may be used to share +// A Context is an opaque type checking context. It may be used to share // identical type instances across type-checked packages or calls to -// Instantiate. +// Instantiate. Contexts are safe for concurrent use. // -// It is safe for concurrent use. +// The use of a shared context does not guarantee that identical instances are +// deduplicated in all cases. type Context struct { mu sync.Mutex typeMap map[string][]ctxtEntry // type hash -> instances entries diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index a48174665739f8206504b17a8e93024c708be83e..8813217eca2ff1361c95c5492e38000a05d1d56e 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -24,7 +24,8 @@ // If ctxt is non-nil, it may be used to de-duplicate the instance against // previous instances with the same identity. As a special case, generic // *Signature origin types are only considered identical if they are pointer // equivalent, so that instantiating distinct (but possibly identical) -// signatures will yield different instances. +// signatures will yield different instances. The use of a shared context does +// not guarantee that identical instances are deduplicated in all cases. // // If validate is set, Instantiate verifies that the number of type arguments // and parameters match, and that the type arguments satisfy their