]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: clarify that contexts do not guarantee deduplication
authorRobert Findley <rfindley@google.com>
Tue, 29 Mar 2022 22:30:06 +0000 (18:30 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 30 Mar 2022 16:23:37 +0000 (16:23 +0000)
Documentation around the use of types.Context is unclear about whether
contexts guarantee deduplication of identical instances. Add explicit
disclaimers that this is not the case.

Fixes golang/go#51680

Change-Id: I6651587315d3cbf9e8d70a69d3e2ec5cedd00da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/396536
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/context.go
src/cmd/compile/internal/types2/instantiate.go
src/go/types/context.go
src/go/types/instantiate.go

index 7abea6b654b34dd738a707c21c3cd11a3ee48669..2d790fe5dddbbf30aa025241daeadfb3a7c2c595 100644 (file)
@@ -12,11 +12,12 @@ import (
        "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
index a511538ccc6b3387c06b46b988912e517561266c..a69a26ba648bd83ccfd03bc77a02cdb05201bb3a 100644 (file)
@@ -24,7 +24,8 @@ import (
 // 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
index ff4bf89f3cb0076abca2a199c2288bee980276a9..692b3a66828a9c593432c1a8a4ad92fc9be0f626 100644 (file)
@@ -12,11 +12,12 @@ import (
        "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
index d7045ff23c0fef11decc8aca46034f1ec52726e6..4450847dfdaff12f94e73962e18b405c70250ce3 100644 (file)
@@ -24,7 +24,8 @@ import (
 // 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