diff options
| author | Mark Freeman <mark@golang.org> | 2026-01-27 10:53:21 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-01-27 08:26:32 -0800 |
| commit | ffb50fb7169f93c502e07868724b1f392267f696 (patch) | |
| tree | bbf05b37a054c9af8cfb53bd48ac9ab261796148 /src/cmd | |
| parent | d8d2b90a4691ab76c757bb72881439b1327f9802 (diff) | |
| download | go-ffb50fb7169f93c502e07868724b1f392267f696.tar.xz | |
go/types, types2: rename Named.finite to Named.varSize
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>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/compile/internal/types2/builtins.go | 17 | ||||
| -rw-r--r-- | src/cmd/compile/internal/types2/named.go | 14 |
2 files changed, 15 insertions, 16 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index b11bacdecf..5965228585 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -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: diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 77e958139f..453ba1466b 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -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) } } |
