types2: better documentation for resolve()

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>
This commit is contained in:
Mark Freeman
2025-08-18 14:32:05 -04:00
committed by Go LUCI
parent 5cf8ca42e3
commit 00824f5ff5
2 changed files with 36 additions and 10 deletions

View 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

View 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