cmd/protoc-gen-go: remove generation of XXX_OneofWrappers
Associate the oneof wrapper types with a message by conveying that
information to the associated MessageInfo.
Change-Id: Iabfca593850e1d6a89498a37eacbf22dbb73bd20
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185239
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/message.go b/internal/impl/message.go
index fcf4b14..82107df 100644
--- a/internal/impl/message.go
+++ b/internal/impl/message.go
@@ -29,6 +29,9 @@
// Once set, this field must never be mutated.
PBType pref.MessageType
+ // OneofWrappers is list of pointers to oneof wrapper struct types.
+ OneofWrappers []interface{}
+
initMu sync.Mutex // protects all unexported fields
initDone uint32
@@ -169,7 +172,7 @@
}
// Derive a mapping of oneof wrappers to fields.
- var oneofWrappers []interface{}
+ oneofWrappers := mi.OneofWrappers
if fn, ok := reflect.PtrTo(t).MethodByName("XXX_OneofFuncs"); ok {
oneofWrappers = fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[3].Interface().([]interface{})
}