]> Cypherpunks repositories - gostls13.git/commitdiff
types2: better documentation for resolve()
authorMark Freeman <mark@golang.org>
Mon, 18 Aug 2025 18:32:05 +0000 (14:32 -0400)
committerGo LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Wed, 10 Sep 2025 20:15:29 +0000 (13:15 -0700)
Change-Id: Iece109dfbdc98d436b845148612f4943598697fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/697697
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/types2/named.go
src/go/types/named.go

index dbb1fa0b3e75f002af8ec6eb31d4f4093afc0c0b..d02b95e874a470c73373389c0a4c96ba6b656eaf 100644 (file)
@@ -162,12 +162,25 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
 }
 
 // resolve resolves the type parameters, methods, and underlying type of n.
-// This information may be loaded from a provided loader function, or computed
-// from an origin type (in the case of instances).
 //
-// After resolution, the type parameters, methods, and underlying type of n are
-// accessible; but if n is an instantiated type, its methods may still be
-// unexpanded.
+// For the purposes of resolution, there are three categories of named types:
+//  1. Instantiated Types
+//  2. Lazy Loaded Types
+//  3. All Others
+//
+// Note that the above form a partition.
+//
+// Instantiated types:
+// Type parameters, methods, and underlying type of n become accessible,
+// though methods are lazily populated as needed.
+//
+// Lazy loaded types:
+// Type parameters, methods, and underlying type of n become accessible
+// and are fully expanded.
+//
+// All others:
+// Effectively, nothing happens. The underlying type of n may still be
+// a named type.
 func (n *Named) resolve() *Named {
        if n.state() > unresolved { // avoid locking below
                return n
index 72fd4970bb33840340f0dfb05ac83dd6cb647dbf..b2f99ffccb90621a8c752b16f47066a8eaf0712d 100644 (file)
@@ -165,12 +165,25 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
 }
 
 // resolve resolves the type parameters, methods, and underlying type of n.
-// This information may be loaded from a provided loader function, or computed
-// from an origin type (in the case of instances).
 //
-// After resolution, the type parameters, methods, and underlying type of n are
-// accessible; but if n is an instantiated type, its methods may still be
-// unexpanded.
+// For the purposes of resolution, there are three categories of named types:
+//  1. Instantiated Types
+//  2. Lazy Loaded Types
+//  3. All Others
+//
+// Note that the above form a partition.
+//
+// Instantiated types:
+// Type parameters, methods, and underlying type of n become accessible,
+// though methods are lazily populated as needed.
+//
+// Lazy loaded types:
+// Type parameters, methods, and underlying type of n become accessible
+// and are fully expanded.
+//
+// All others:
+// Effectively, nothing happens. The underlying type of n may still be
+// a named type.
 func (n *Named) resolve() *Named {
        if n.state() > unresolved { // avoid locking below
                return n