From: Mark Freeman Date: Wed, 10 Dec 2025 19:13:00 +0000 (-0500) Subject: go/types, types2: remove indirection of Named.finite X-Git-Tag: go1.26rc1~1^2~19 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2622d2955b;p=gostls13.git go/types, types2: remove indirection of Named.finite This field is now guarded by a state bit. The "unknown" state is hence indicated by absence of that bit. Change-Id: I9605538f089dd4fd638e5f0f416cd4b8737b6f88 Reviewed-on: https://go-review.googlesource.com/c/go/+/729041 Reviewed-by: Robert Griesemer Auto-Submit: Mark Freeman LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/types2/cycles.go b/src/cmd/compile/internal/types2/cycles.go index 09229617f0..84a05c9647 100644 --- a/src/cmd/compile/internal/types2/cycles.go +++ b/src/cmd/compile/internal/types2/cycles.go @@ -110,7 +110,7 @@ func (check *Checker) finiteSize(t Type) bool { switch t := Unalias(t).(type) { case *Named: if t.stateHas(hasFinite) { - return *t.finite + return t.finite } if i, ok := check.objPathIdx[t.obj]; ok { @@ -129,7 +129,7 @@ func (check *Checker) finiteSize(t Type) bool { // another call to finiteSize, we have to avoid overwriting t.finite. // Otherwise, the race detector will be tripped. if !t.stateHas(hasFinite) { - t.finite = &isFinite + t.finite = isFinite t.setState(hasFinite) } diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 6b31d6d5df..2922fb55eb 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -117,7 +117,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, or nil + finite bool // whether the type has finite size // methods declared for this type (not the method set of this type) // Signatures are type-checked lazily. diff --git a/src/go/types/cycles.go b/src/go/types/cycles.go index 68868fcc76..9f1e0e8b58 100644 --- a/src/go/types/cycles.go +++ b/src/go/types/cycles.go @@ -113,7 +113,7 @@ func (check *Checker) finiteSize(t Type) bool { switch t := Unalias(t).(type) { case *Named: if t.stateHas(hasFinite) { - return *t.finite + return t.finite } if i, ok := check.objPathIdx[t.obj]; ok { @@ -132,7 +132,7 @@ func (check *Checker) finiteSize(t Type) bool { // another call to finiteSize, we have to avoid overwriting t.finite. // Otherwise, the race detector will be tripped. if !t.stateHas(hasFinite) { - t.finite = &isFinite + t.finite = isFinite t.setState(hasFinite) } diff --git a/src/go/types/named.go b/src/go/types/named.go index 5925a40c00..3b618f403d 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -120,7 +120,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, or nil + finite bool // whether the type has finite size // methods declared for this type (not the method set of this type) // Signatures are type-checked lazily.