]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: rename loaded namedState to lazyLoaded
authorMark Freeman <mark@golang.org>
Mon, 20 Oct 2025 20:29:44 +0000 (16:29 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 23 Oct 2025 20:16:51 +0000 (13:16 -0700)
This is a minor renaming to help differentiate the two kinds of loading
that can happen for named types (eager and lazy).

Use of the term "loaded" suggests that it might also apply to types
which are eagerly-loaded, which is not the case. This change uses
"lazyLoaded" instead to mark this difference.

Change-Id: Iee170024246d9adf3eed978bde2b0500f6d490b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/713282
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: 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 0823839d81c6468d1240a4f2bc4e053b94b0fec0..a275e26a0c39b84cf2354e10c983cfbc89aabf67 100644 (file)
@@ -142,7 +142,7 @@ type instance struct {
 // according to the below diagram:
 //
 //     unresolved
-//     loaded
+//     lazyLoaded
 //     resolved
 //     └── hasMethods
 //     └── hasUnder
@@ -158,9 +158,9 @@ type instance struct {
 // set left-to-right, they are:
 //
 //     0000 | unresolved
-//     1000 | loaded
-//     1100 | resolved, which implies loaded
-//     1110 | hasMethods, which implies resolved (which in turn implies loaded)
+//     1000 | lazyLoaded
+//     1100 | resolved, which implies lazyLoaded
+//     1110 | hasMethods, which implies resolved (which in turn implies lazyLoaded)
 //     1101 | hasUnder, which implies resolved ...
 //     1111 | both hasMethods and hasUnder which implies resolved ...
 //
@@ -169,9 +169,9 @@ type stateMask uint32
 
 const (
        // before resolved, type parameters, RHS, underlying, and methods might be unavailable
-       resolved   stateMask = 1 << iota // methods might be unexpanded (for instances)
+       lazyLoaded stateMask = 1 << iota // methods are available, but constraints might be unexpanded (for generic types)
+       resolved                         // methods might be unexpanded (for instances)
        hasMethods                       // methods are all expanded (for instances)
-       loaded                           // methods are available, but constraints might be unexpanded (for generic types)
        hasUnder                         // underlying type is available
 )
 
@@ -213,7 +213,7 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
 // All others:
 // Effectively, nothing happens.
 func (n *Named) resolve() *Named {
-       if n.stateHas(resolved | loaded) { // avoid locking below
+       if n.stateHas(resolved | lazyLoaded) { // avoid locking below
                return n
        }
 
@@ -223,7 +223,7 @@ func (n *Named) resolve() *Named {
        defer n.mu.Unlock()
 
        // only atomic for consistency; we are holding the mutex
-       if n.stateHas(resolved | loaded) {
+       if n.stateHas(resolved | lazyLoaded) {
                return n
        }
 
@@ -267,7 +267,7 @@ func (n *Named) resolve() *Named {
                n.fromRHS = underlying // for cycle detection
                n.methods = methods
 
-               n.setState(loaded) // avoid deadlock calling delayed functions
+               n.setState(lazyLoaded) // avoid deadlock calling delayed functions
                for _, f := range delayed {
                        f()
                }
@@ -716,7 +716,7 @@ func (n *Named) expandRHS() (rhs Type) {
        }
 
        assert(!n.stateHas(resolved))
-       assert(n.inst.orig.stateHas(resolved | loaded))
+       assert(n.inst.orig.stateHas(resolved | lazyLoaded))
 
        if n.inst.ctxt == nil {
                n.inst.ctxt = NewContext()
index a0cb9abba1ab14a13ba527a7182944f64dd816e1..afdd68ae7f64404fa9768a1166f7b14d269ad4c5 100644 (file)
@@ -145,7 +145,7 @@ type instance struct {
 // according to the below diagram:
 //
 //     unresolved
-//     loaded
+//     lazyLoaded
 //     resolved
 //     └── hasMethods
 //     └── hasUnder
@@ -161,9 +161,9 @@ type instance struct {
 // set left-to-right, they are:
 //
 //     0000 | unresolved
-//     1000 | loaded
-//     1100 | resolved, which implies loaded
-//     1110 | hasMethods, which implies resolved (which in turn implies loaded)
+//     1000 | lazyLoaded
+//     1100 | resolved, which implies lazyLoaded
+//     1110 | hasMethods, which implies resolved (which in turn implies lazyLoaded)
 //     1101 | hasUnder, which implies resolved ...
 //     1111 | both hasMethods and hasUnder which implies resolved ...
 //
@@ -172,9 +172,9 @@ type stateMask uint32
 
 const (
        // before resolved, type parameters, RHS, underlying, and methods might be unavailable
-       resolved   stateMask = 1 << iota // methods might be unexpanded (for instances)
+       lazyLoaded stateMask = 1 << iota // methods are available, but constraints might be unexpanded (for generic types)
+       resolved                         // methods might be unexpanded (for instances)
        hasMethods                       // methods are all expanded (for instances)
-       loaded                           // methods are available, but constraints might be unexpanded (for generic types)
        hasUnder                         // underlying type is available
 )
 
@@ -216,7 +216,7 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
 // All others:
 // Effectively, nothing happens.
 func (n *Named) resolve() *Named {
-       if n.stateHas(resolved | loaded) { // avoid locking below
+       if n.stateHas(resolved | lazyLoaded) { // avoid locking below
                return n
        }
 
@@ -226,7 +226,7 @@ func (n *Named) resolve() *Named {
        defer n.mu.Unlock()
 
        // only atomic for consistency; we are holding the mutex
-       if n.stateHas(resolved | loaded) {
+       if n.stateHas(resolved | lazyLoaded) {
                return n
        }
 
@@ -270,7 +270,7 @@ func (n *Named) resolve() *Named {
                n.fromRHS = underlying // for cycle detection
                n.methods = methods
 
-               n.setState(loaded) // avoid deadlock calling delayed functions
+               n.setState(lazyLoaded) // avoid deadlock calling delayed functions
                for _, f := range delayed {
                        f()
                }
@@ -719,7 +719,7 @@ func (n *Named) expandRHS() (rhs Type) {
        }
 
        assert(!n.stateHas(resolved))
-       assert(n.inst.orig.stateHas(resolved | loaded))
+       assert(n.inst.orig.stateHas(resolved | lazyLoaded))
 
        if n.inst.ctxt == nil {
                n.inst.ctxt = NewContext()