]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: rename Named.finite to Named.varSize
authorMark Freeman <mark@golang.org>
Tue, 27 Jan 2026 15:53:21 +0000 (10:53 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 27 Jan 2026 16:26:32 +0000 (08:26 -0800)
Change-Id: I81646c2753c2e44953b116138cb41d41a011ff08
Reviewed-on: https://go-review.googlesource.com/c/go/+/739561
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/named.go
src/go/types/builtins.go
src/go/types/named.go

index b11bacdecf8e8c81a7d6b10c362d6749467d37ce..59652285853b0b732a5315e6ec26064d29e6b78f 100644 (file)
@@ -1012,9 +1012,8 @@ func (check *Checker) hasVarSize(t Type) bool {
        // better error messages.
        switch t := Unalias(t).(type) {
        case *Named:
-               if t.stateHas(hasFinite) {
-                       // TODO(mark): Rename t.finite to t.varSize to avoid inversion.
-                       return !t.finite
+               if t.stateHas(hasVarSize) {
+                       return t.varSize
                }
 
                if i, ok := check.objPathIdx[t.obj]; ok {
@@ -1031,19 +1030,19 @@ func (check *Checker) hasVarSize(t Type) bool {
                t.mu.Lock()
                defer t.mu.Unlock()
 
-               // Careful, t.finite has lock-free readers. Since we might be racing
-               // another call to finiteSize, we have to avoid overwriting t.finite.
+               // Careful, t.varSize has lock-free readers. Since we might be racing
+               // another call to hasVarSize, we have to avoid overwriting t.varSize.
                // Otherwise, the race detector will be tripped.
-               if !t.stateHas(hasFinite) {
-                       t.finite = !varSize
-                       t.setState(hasFinite)
+               if !t.stateHas(hasVarSize) {
+                       t.varSize = varSize
+                       t.setState(hasVarSize)
                }
 
                return varSize
 
        case *Array:
                // The array length is already computed. If it was a valid length, it
-               // is finite; else, an error was reported in the computation.
+               // is constant; else, an error was reported in the computation.
                return check.hasVarSize(t.elem)
 
        case *Struct:
index 77e958139f7c6bcdac7dca2fb3c87c9b3679dbf1..453ba1466be4d59ff0f8e49ec72f64fb4714e9db 100644 (file)
@@ -115,7 +115,7 @@ type Named struct {
        fromRHS    Type           // the declaration RHS this type is derived from
        tparams    *TypeParamList // type parameters, or nil
        underlying Type           // underlying type, or nil
-       finite     bool           // whether the type has finite size
+       varSize    bool           // whether the type has variable size
 
        // methods declared for this type (not the method set of this type)
        // Signatures are type-checked lazily.
@@ -147,10 +147,10 @@ type instance struct {
 //     unpacked
 //     └── hasMethods
 //     └── hasUnder
-//     └── hasFinite
+//     └── hasVarSize
 //
 // That is, descent down the tree is mostly linear (initial through unpacked), except upon
-// reaching the leaves (hasMethods, hasUnder, and hasFinite). A type may occupy any
+// reaching the leaves (hasMethods, hasUnder, and hasVarSize). A type may occupy any
 // combination of the leaf states at once (they are independent states).
 //
 // To represent this independence, the set of active states is represented with a bit set. State
@@ -164,7 +164,7 @@ type instance struct {
 //     11000 | unpacked, which implies lazyLoaded
 //     11100 | hasMethods, which implies unpacked (which in turn implies lazyLoaded)
 //     11010 | hasUnder, which implies unpacked ...
-//     11001 | hasFinite, which implies unpacked ...
+//     11001 | hasVarSize, which implies unpacked ...
 //     11110 | both hasMethods and hasUnder which implies unpacked ...
 //     ...   | (other combinations of leaf states)
 //
@@ -177,7 +177,7 @@ const (
        unpacked                         // methods might be unexpanded (for instances)
        hasMethods                       // methods are all expanded (for instances)
        hasUnder                         // underlying type is available
-       hasFinite                        // size finiteness is available
+       hasVarSize                       // varSize is available
 )
 
 // NewNamed returns a new named type for the given type name, underlying type, and associated methods.
@@ -306,8 +306,8 @@ func (n *Named) setState(m stateMask) {
                if m&hasUnder != 0 {
                        assert(u)
                }
-               // hasFinite => unpacked
-               if m&hasFinite != 0 {
+               // hasVarSize => unpacked
+               if m&hasVarSize != 0 {
                        assert(u)
                }
        }
index bf0b8a4b4bc73dc662936508f654f7bb5c617c06..aea2997f32e890882567c60cdb719c6c9e6c78e7 100644 (file)
@@ -1015,9 +1015,8 @@ func (check *Checker) hasVarSize(t Type) bool {
        // better error messages.
        switch t := Unalias(t).(type) {
        case *Named:
-               if t.stateHas(hasFinite) {
-                       // TODO(mark): Rename t.finite to t.varSize to avoid inversion.
-                       return !t.finite
+               if t.stateHas(hasVarSize) {
+                       return t.varSize
                }
 
                if i, ok := check.objPathIdx[t.obj]; ok {
@@ -1034,19 +1033,19 @@ func (check *Checker) hasVarSize(t Type) bool {
                t.mu.Lock()
                defer t.mu.Unlock()
 
-               // Careful, t.finite has lock-free readers. Since we might be racing
-               // another call to finiteSize, we have to avoid overwriting t.finite.
+               // Careful, t.varSize has lock-free readers. Since we might be racing
+               // another call to hasVarSize, we have to avoid overwriting t.varSize.
                // Otherwise, the race detector will be tripped.
-               if !t.stateHas(hasFinite) {
-                       t.finite = !varSize
-                       t.setState(hasFinite)
+               if !t.stateHas(hasVarSize) {
+                       t.varSize = varSize
+                       t.setState(hasVarSize)
                }
 
                return varSize
 
        case *Array:
                // The array length is already computed. If it was a valid length, it
-               // is finite; else, an error was reported in the computation.
+               // is constant; else, an error was reported in the computation.
                return check.hasVarSize(t.elem)
 
        case *Struct:
index 42f33e6af494361d211707748d6f4a58b112e47b..5e0f44d7ff6133ebef722eae4a37ae8256e1340b 100644 (file)
@@ -118,7 +118,7 @@ type Named struct {
        fromRHS    Type           // the declaration RHS this type is derived from
        tparams    *TypeParamList // type parameters, or nil
        underlying Type           // underlying type, or nil
-       finite     bool           // whether the type has finite size
+       varSize    bool           // whether the type has variable size
 
        // methods declared for this type (not the method set of this type)
        // Signatures are type-checked lazily.
@@ -150,10 +150,10 @@ type instance struct {
 //     unpacked
 //     └── hasMethods
 //     └── hasUnder
-//     └── hasFinite
+//     └── hasVarSize
 //
 // That is, descent down the tree is mostly linear (initial through unpacked), except upon
-// reaching the leaves (hasMethods, hasUnder, and hasFinite). A type may occupy any
+// reaching the leaves (hasMethods, hasUnder, and hasVarSize). A type may occupy any
 // combination of the leaf states at once (they are independent states).
 //
 // To represent this independence, the set of active states is represented with a bit set. State
@@ -167,7 +167,7 @@ type instance struct {
 //     11000 | unpacked, which implies lazyLoaded
 //     11100 | hasMethods, which implies unpacked (which in turn implies lazyLoaded)
 //     11010 | hasUnder, which implies unpacked ...
-//     11001 | hasFinite, which implies unpacked ...
+//     11001 | hasVarSize, which implies unpacked ...
 //     11110 | both hasMethods and hasUnder which implies unpacked ...
 //     ...   | (other combinations of leaf states)
 //
@@ -180,7 +180,7 @@ const (
        unpacked                         // methods might be unexpanded (for instances)
        hasMethods                       // methods are all expanded (for instances)
        hasUnder                         // underlying type is available
-       hasFinite                        // size finiteness is available
+       hasVarSize                       // varSize is available
 )
 
 // NewNamed returns a new named type for the given type name, underlying type, and associated methods.
@@ -309,8 +309,8 @@ func (n *Named) setState(m stateMask) {
                if m&hasUnder != 0 {
                        assert(u)
                }
-               // hasFinite => unpacked
-               if m&hasFinite != 0 {
+               // hasVarSize => unpacked
+               if m&hasVarSize != 0 {
                        assert(u)
                }
        }