diff options
| author | Keith Randall <khr@golang.org> | 2025-06-14 20:10:50 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2025-08-05 09:18:31 -0700 |
| commit | cd55f86b8dcfc139ee5c17d32530ac9e758c8bc0 (patch) | |
| tree | 4b734bf249c12b9f3cbd1865f54cfd722e91508b /src/reflect | |
| parent | 21ab0128b62658ba3e325586f45bb781bee55fda (diff) | |
| download | go-cd55f86b8dcfc139ee5c17d32530ac9e758c8bc0.tar.xz | |
cmd/compile: allow multi-field structs to be stored directly in interfaces
If the struct is a bunch of 0-sized fields and one pointer field.
Fixes #74092
Change-Id: I87c5d162c8c9fdba812420d7f9d21de97295b62c
Reviewed-on: https://go-review.googlesource.com/c/go/+/681937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/reflect')
| -rw-r--r-- | src/reflect/type.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go index cec8662c01..19a28abfcf 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -2524,8 +2524,7 @@ func StructOf(fields []StructField) Type { } switch { - case len(fs) == 1 && fs[0].Typ.IsDirectIface(): - // structs of 1 direct iface type can be direct + case typ.Size_ == goarch.PtrSize && typ.PtrBytes == goarch.PtrSize: typ.TFlag |= abi.TFlagDirectIface default: typ.TFlag &^= abi.TFlagDirectIface @@ -2694,8 +2693,7 @@ func ArrayOf(length int, elem Type) Type { } switch { - case length == 1 && typ.IsDirectIface(): - // array of 1 direct iface type can be direct + case array.Size_ == goarch.PtrSize && array.PtrBytes == goarch.PtrSize: array.TFlag |= abi.TFlagDirectIface default: array.TFlag &^= abi.TFlagDirectIface |
