// 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 {
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:
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.
// 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
// 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)
//
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.
if m&hasUnder != 0 {
assert(u)
}
- // hasFinite => unpacked
- if m&hasFinite != 0 {
+ // hasVarSize => unpacked
+ if m&hasVarSize != 0 {
assert(u)
}
}
// 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 {
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:
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.
// 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
// 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)
//
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.
if m&hasUnder != 0 {
assert(u)
}
- // hasFinite => unpacked
- if m&hasFinite != 0 {
+ // hasVarSize => unpacked
+ if m&hasVarSize != 0 {
assert(u)
}
}