blob: 938c44cb637fde057dedf8992af5f6e5491c9d8a [file] [log] [blame]
Joe Tsai90fe9962018-10-18 11:06:29 -07001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Joe Tsai21ade492019-05-22 13:42:54 -04005package impl
Joe Tsai90fe9962018-10-18 11:06:29 -07006
7import (
8 "fmt"
Joe Tsai90fe9962018-10-18 11:06:29 -07009 "reflect"
Joe Tsai851185d2019-07-01 13:45:52 -070010 "strings"
Joe Tsai90fe9962018-10-18 11:06:29 -070011 "sync"
Joe Tsai90fe9962018-10-18 11:06:29 -070012
Joe Tsai851185d2019-07-01 13:45:52 -070013 "google.golang.org/protobuf/internal/descopts"
14 ptag "google.golang.org/protobuf/internal/encoding/tag"
Damien Neil47d58932019-09-30 15:34:27 -070015 "google.golang.org/protobuf/internal/errors"
Joe Tsai851185d2019-07-01 13:45:52 -070016 "google.golang.org/protobuf/internal/filedesc"
Joe Tsai97a87392019-07-07 01:49:59 -070017 "google.golang.org/protobuf/internal/strs"
Joe Tsaid8881392019-06-06 13:01:53 -070018 "google.golang.org/protobuf/reflect/protoreflect"
Damien Neile89e6242019-05-13 23:55:40 -070019 pref "google.golang.org/protobuf/reflect/protoreflect"
Damien Neil37ef6912019-09-25 16:51:15 -070020 piface "google.golang.org/protobuf/runtime/protoiface"
Joe Tsai90fe9962018-10-18 11:06:29 -070021)
22
Joe Tsai21ade492019-05-22 13:42:54 -040023// legacyWrapMessage wraps v as a protoreflect.ProtoMessage,
Joe Tsaif0c01e42018-11-06 13:05:20 -080024// where v must be a *struct kind and not implement the v2 API already.
Joe Tsai21ade492019-05-22 13:42:54 -040025func legacyWrapMessage(v reflect.Value) pref.ProtoMessage {
Damien Neil47d58932019-09-30 15:34:27 -070026 typ := v.Type()
27 if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct {
28 return aberrantMessage{v: v}
29 }
30 mt := legacyLoadMessageInfo(typ, "")
Joe Tsai08e00302018-11-26 22:32:06 -080031 return mt.MessageOf(v.Interface()).Interface()
Joe Tsaif0c01e42018-11-06 13:05:20 -080032}
33
Joe Tsai21ade492019-05-22 13:42:54 -040034var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo
Joe Tsaice6edd32018-10-19 16:27:46 -070035
Joe Tsai21ade492019-05-22 13:42:54 -040036// legacyLoadMessageInfo dynamically loads a *MessageInfo for t,
Joe Tsaif0c01e42018-11-06 13:05:20 -080037// where t must be a *struct kind and not implement the v2 API already.
Joe Tsaiea5ada12019-09-04 22:41:40 -070038// The provided name is used if it cannot be determined from the message.
39func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
Joe Tsai4fe96632019-05-22 05:12:36 -040040 // Fast-path: check if a MessageInfo is cached for this concrete type.
Joe Tsai21ade492019-05-22 13:42:54 -040041 if mt, ok := legacyMessageTypeCache.Load(t); ok {
42 return mt.(*MessageInfo)
Joe Tsaice6edd32018-10-19 16:27:46 -070043 }
44
Joe Tsai4fe96632019-05-22 05:12:36 -040045 // Slow-path: derive message descriptor and initialize MessageInfo.
Damien Neil16163b42019-08-06 15:43:25 -070046 mi := &MessageInfo{
Joe Tsaiea5ada12019-09-04 22:41:40 -070047 Desc: legacyLoadMessageDesc(t, name),
Damien Neil16163b42019-08-06 15:43:25 -070048 GoReflectType: t,
Joe Tsaib2f66be2019-05-22 00:42:45 -040049 }
Damien Neil37ef6912019-09-25 16:51:15 -070050
51 v := reflect.Zero(t).Interface()
Damien Neil47d58932019-09-30 15:34:27 -070052 if _, ok := v.(legacyMarshaler); ok {
53 mi.methods.MarshalAppend = legacyMarshalAppend
54 mi.methods.Size = legacySize
Damien Neil37ef6912019-09-25 16:51:15 -070055 }
Damien Neil47d58932019-09-30 15:34:27 -070056 if _, ok := v.(legacyUnmarshaler); ok {
57 mi.methods.Unmarshal = legacyUnmarshal
Damien Neil37ef6912019-09-25 16:51:15 -070058 }
59
Damien Neil16163b42019-08-06 15:43:25 -070060 if mi, ok := legacyMessageTypeCache.LoadOrStore(t, mi); ok {
61 return mi.(*MessageInfo)
Joe Tsaib9365042019-03-19 14:14:29 -070062 }
Damien Neil16163b42019-08-06 15:43:25 -070063 return mi
Joe Tsaice6edd32018-10-19 16:27:46 -070064}
65
Joe Tsaid8881392019-06-06 13:01:53 -070066var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
Joe Tsai90fe9962018-10-18 11:06:29 -070067
Joe Tsai21ade492019-05-22 13:42:54 -040068// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
Joe Tsaice6edd32018-10-19 16:27:46 -070069// which must be a *struct kind and not implement the v2 API already.
Joe Tsai35ec98f2019-03-25 14:41:32 -070070//
71// This is exported for testing purposes.
Joe Tsai21ade492019-05-22 13:42:54 -040072func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
Joe Tsaiea5ada12019-09-04 22:41:40 -070073 return legacyLoadMessageDesc(t, "")
74}
75func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai90fe9962018-10-18 11:06:29 -070076 // Fast-path: check if a MessageDescriptor is cached for this concrete type.
Joe Tsai21ade492019-05-22 13:42:54 -040077 if mi, ok := legacyMessageDescCache.Load(t); ok {
Joe Tsai90fe9962018-10-18 11:06:29 -070078 return mi.(pref.MessageDescriptor)
79 }
80
Joe Tsaid8881392019-06-06 13:01:53 -070081 // Slow-path: initialize MessageDescriptor from the raw descriptor.
Damien Neil47d58932019-09-30 15:34:27 -070082 mv := reflect.Zero(t).Interface()
Joe Tsai90fe9962018-10-18 11:06:29 -070083 if _, ok := mv.(pref.ProtoMessage); ok {
84 panic(fmt.Sprintf("%v already implements proto.Message", t))
85 }
Joe Tsaid8881392019-06-06 13:01:53 -070086 mdV1, ok := mv.(messageV1)
87 if !ok {
Joe Tsaiea5ada12019-09-04 22:41:40 -070088 return aberrantLoadMessageDesc(t, name)
Joe Tsaid8881392019-06-06 13:01:53 -070089 }
90 b, idxs := mdV1.Descriptor()
Joe Tsai90fe9962018-10-18 11:06:29 -070091
Joe Tsaid8881392019-06-06 13:01:53 -070092 md := legacyLoadFileDesc(b).Messages().Get(idxs[0])
93 for _, i := range idxs[1:] {
94 md = md.Messages().Get(i)
Joe Tsai90fe9962018-10-18 11:06:29 -070095 }
Joe Tsaiea5ada12019-09-04 22:41:40 -070096 if name != "" && md.FullName() != name {
97 panic(fmt.Sprintf("mismatching message name: got %v, want %v", md.FullName(), name))
98 }
Joe Tsaid8881392019-06-06 13:01:53 -070099 if md, ok := legacyMessageDescCache.LoadOrStore(t, md); ok {
100 return md.(protoreflect.MessageDescriptor)
Joe Tsai90fe9962018-10-18 11:06:29 -0700101 }
Joe Tsaid8881392019-06-06 13:01:53 -0700102 return md
Joe Tsai90fe9962018-10-18 11:06:29 -0700103}
Joe Tsai851185d2019-07-01 13:45:52 -0700104
Joe Tsai32e8a522019-07-02 10:51:24 -0700105var (
106 aberrantMessageDescLock sync.Mutex
107 aberrantMessageDescCache map[reflect.Type]protoreflect.MessageDescriptor
108)
Joe Tsai851185d2019-07-01 13:45:52 -0700109
Damien Neil47d58932019-09-30 15:34:27 -0700110// aberrantLoadMessageDesc returns an MessageDescriptor derived from the Go type,
Joe Tsai851185d2019-07-01 13:45:52 -0700111// which must not implement protoreflect.ProtoMessage or messageV1.
112//
113// This is a best-effort derivation of the message descriptor using the protobuf
114// tags on the struct fields.
Joe Tsaiea5ada12019-09-04 22:41:40 -0700115func aberrantLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai32e8a522019-07-02 10:51:24 -0700116 aberrantMessageDescLock.Lock()
117 defer aberrantMessageDescLock.Unlock()
118 if aberrantMessageDescCache == nil {
119 aberrantMessageDescCache = make(map[reflect.Type]protoreflect.MessageDescriptor)
120 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700121 return aberrantLoadMessageDescReentrant(t, name)
Joe Tsai32e8a522019-07-02 10:51:24 -0700122}
Joe Tsaiea5ada12019-09-04 22:41:40 -0700123func aberrantLoadMessageDescReentrant(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai851185d2019-07-01 13:45:52 -0700124 // Fast-path: check if an MessageDescriptor is cached for this concrete type.
Joe Tsai32e8a522019-07-02 10:51:24 -0700125 if md, ok := aberrantMessageDescCache[t]; ok {
126 return md
Joe Tsai851185d2019-07-01 13:45:52 -0700127 }
128
Joe Tsai851185d2019-07-01 13:45:52 -0700129 // Slow-path: construct a descriptor from the Go struct type (best-effort).
Joe Tsai32e8a522019-07-02 10:51:24 -0700130 // Cache the MessageDescriptor early on so that we can resolve internal
131 // cyclic references.
132 md := &filedesc.Message{L2: new(filedesc.MessageL2)}
Damien Neil47d58932019-09-30 15:34:27 -0700133 md.L0.FullName = aberrantDeriveMessageName(t, name)
Joe Tsai851185d2019-07-01 13:45:52 -0700134 md.L0.ParentFile = filedesc.SurrogateProto2
Joe Tsai32e8a522019-07-02 10:51:24 -0700135 aberrantMessageDescCache[t] = md
Joe Tsai851185d2019-07-01 13:45:52 -0700136
Damien Neil47d58932019-09-30 15:34:27 -0700137 if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
138 return md
139 }
140
Joe Tsai851185d2019-07-01 13:45:52 -0700141 // Try to determine if the message is using proto3 by checking scalars.
142 for i := 0; i < t.Elem().NumField(); i++ {
143 f := t.Elem().Field(i)
144 if tag := f.Tag.Get("protobuf"); tag != "" {
145 switch f.Type.Kind() {
146 case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
147 md.L0.ParentFile = filedesc.SurrogateProto3
148 }
149 for _, s := range strings.Split(tag, ",") {
150 if s == "proto3" {
151 md.L0.ParentFile = filedesc.SurrogateProto3
152 }
153 }
154 }
155 }
156
157 // Obtain a list of oneof wrapper types.
158 var oneofWrappers []reflect.Type
159 if fn, ok := t.MethodByName("XXX_OneofFuncs"); ok {
160 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[3]
161 for _, v := range vs.Interface().([]interface{}) {
162 oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
163 }
164 }
165 if fn, ok := t.MethodByName("XXX_OneofWrappers"); ok {
166 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0]
167 for _, v := range vs.Interface().([]interface{}) {
168 oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
169 }
170 }
171
172 // Obtain a list of the extension ranges.
173 if fn, ok := t.MethodByName("ExtensionRangeArray"); ok {
174 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0]
175 for i := 0; i < vs.Len(); i++ {
176 v := vs.Index(i)
177 md.L2.ExtensionRanges.List = append(md.L2.ExtensionRanges.List, [2]pref.FieldNumber{
178 pref.FieldNumber(v.FieldByName("Start").Int()),
179 pref.FieldNumber(v.FieldByName("End").Int() + 1),
180 })
181 md.L2.ExtensionRangeOptions = append(md.L2.ExtensionRangeOptions, nil)
182 }
183 }
184
185 // Derive the message fields by inspecting the struct fields.
186 for i := 0; i < t.Elem().NumField(); i++ {
187 f := t.Elem().Field(i)
188 if tag := f.Tag.Get("protobuf"); tag != "" {
189 tagKey := f.Tag.Get("protobuf_key")
190 tagVal := f.Tag.Get("protobuf_val")
191 aberrantAppendField(md, f.Type, tag, tagKey, tagVal)
192 }
193 if tag := f.Tag.Get("protobuf_oneof"); tag != "" {
194 n := len(md.L2.Oneofs.List)
195 md.L2.Oneofs.List = append(md.L2.Oneofs.List, filedesc.Oneof{})
196 od := &md.L2.Oneofs.List[n]
197 od.L0.FullName = md.FullName().Append(pref.Name(tag))
198 od.L0.ParentFile = md.L0.ParentFile
199 od.L0.Parent = md
200 od.L0.Index = n
201
202 for _, t := range oneofWrappers {
203 if t.Implements(f.Type) {
204 f := t.Elem().Field(0)
205 if tag := f.Tag.Get("protobuf"); tag != "" {
206 aberrantAppendField(md, f.Type, tag, "", "")
207 fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1]
208 fd.L1.ContainingOneof = od
209 od.L1.Fields.List = append(od.L1.Fields.List, fd)
210 }
211 }
212 }
213 }
214 }
215
Joe Tsai851185d2019-07-01 13:45:52 -0700216 return md
217}
218
Joe Tsaiea5ada12019-09-04 22:41:40 -0700219func aberrantDeriveMessageName(t reflect.Type, name pref.FullName) pref.FullName {
220 if name.IsValid() {
221 return name
222 }
Joe Tsaie87cf532019-09-10 12:20:00 -0700223 func() {
224 defer func() { recover() }() // swallow possible nil panics
Damien Neil47d58932019-09-30 15:34:27 -0700225 if m, ok := reflect.Zero(t).Interface().(interface{ XXX_MessageName() string }); ok {
Joe Tsaie87cf532019-09-10 12:20:00 -0700226 name = pref.FullName(m.XXX_MessageName())
Joe Tsaiea5ada12019-09-04 22:41:40 -0700227 }
Joe Tsaie87cf532019-09-10 12:20:00 -0700228 }()
229 if name.IsValid() {
230 return name
Joe Tsaiea5ada12019-09-04 22:41:40 -0700231 }
Damien Neil47d58932019-09-30 15:34:27 -0700232 if t.Kind() == reflect.Ptr {
233 t = t.Elem()
234 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700235 return aberrantDeriveFullName(t)
236}
237
Joe Tsai851185d2019-07-01 13:45:52 -0700238func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey, tagVal string) {
239 t := goType
240 isOptional := t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct
241 isRepeated := t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8
242 if isOptional || isRepeated {
243 t = t.Elem()
244 }
245 fd := ptag.Unmarshal(tag, t, placeholderEnumValues{}).(*filedesc.Field)
246
247 // Append field descriptor to the message.
248 n := len(md.L2.Fields.List)
249 md.L2.Fields.List = append(md.L2.Fields.List, *fd)
250 fd = &md.L2.Fields.List[n]
251 fd.L0.FullName = md.FullName().Append(fd.Name())
252 fd.L0.ParentFile = md.L0.ParentFile
253 fd.L0.Parent = md
254 fd.L0.Index = n
255
256 if fd.L1.IsWeak || fd.L1.HasPacked {
257 fd.L1.Options = func() pref.ProtoMessage {
258 opts := descopts.Field.ProtoReflect().New()
259 if fd.L1.IsWeak {
Joe Tsai84177c92019-09-17 13:38:48 -0700260 opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
Joe Tsai851185d2019-07-01 13:45:52 -0700261 }
262 if fd.L1.HasPacked {
Joe Tsai84177c92019-09-17 13:38:48 -0700263 opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked))
Joe Tsai851185d2019-07-01 13:45:52 -0700264 }
265 return opts.Interface()
266 }
267 }
268
269 // Populate Enum and Message.
270 if fd.Enum() == nil && fd.Kind() == pref.EnumKind {
271 switch v := reflect.Zero(t).Interface().(type) {
272 case pref.Enum:
273 fd.L1.Enum = v.Descriptor()
274 default:
275 fd.L1.Enum = LegacyLoadEnumDesc(t)
276 }
277 }
278 if fd.Message() == nil && (fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind) {
279 switch v := reflect.Zero(t).Interface().(type) {
280 case pref.ProtoMessage:
281 fd.L1.Message = v.ProtoReflect().Descriptor()
Joe Tsai32e8a522019-07-02 10:51:24 -0700282 case messageV1:
283 fd.L1.Message = LegacyLoadMessageDesc(t)
Joe Tsai851185d2019-07-01 13:45:52 -0700284 default:
285 if t.Kind() == reflect.Map {
286 n := len(md.L1.Messages.List)
287 md.L1.Messages.List = append(md.L1.Messages.List, filedesc.Message{L2: new(filedesc.MessageL2)})
288 md2 := &md.L1.Messages.List[n]
Joe Tsai97a87392019-07-07 01:49:59 -0700289 md2.L0.FullName = md.FullName().Append(pref.Name(strs.MapEntryName(string(fd.Name()))))
Joe Tsai851185d2019-07-01 13:45:52 -0700290 md2.L0.ParentFile = md.L0.ParentFile
291 md2.L0.Parent = md
292 md2.L0.Index = n
293
294 md2.L2.IsMapEntry = true
295 md2.L2.Options = func() pref.ProtoMessage {
296 opts := descopts.Message.ProtoReflect().New()
Joe Tsai84177c92019-09-17 13:38:48 -0700297 opts.Set(opts.Descriptor().Fields().ByName("map_entry"), protoreflect.ValueOfBool(true))
Joe Tsai851185d2019-07-01 13:45:52 -0700298 return opts.Interface()
299 }
300
301 aberrantAppendField(md2, t.Key(), tagKey, "", "")
302 aberrantAppendField(md2, t.Elem(), tagVal, "", "")
303
304 fd.L1.Message = md2
305 break
306 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700307 fd.L1.Message = aberrantLoadMessageDescReentrant(t, "")
Joe Tsai851185d2019-07-01 13:45:52 -0700308 }
309 }
310}
311
312type placeholderEnumValues struct {
313 protoreflect.EnumValueDescriptors
314}
315
316func (placeholderEnumValues) ByNumber(n pref.EnumNumber) pref.EnumValueDescriptor {
317 return filedesc.PlaceholderEnumValue(pref.FullName(fmt.Sprintf("UNKNOWN_%d", n)))
318}
Damien Neil47d58932019-09-30 15:34:27 -0700319
320// legacyMarshaler is the proto.Marshaler interface superseded by protoiface.Methoder.
321type legacyMarshaler interface {
322 Marshal() ([]byte, error)
323}
324
325// legacyUnmarshaler is the proto.Unmarshaler interface superseded by protoiface.Methoder.
326type legacyUnmarshaler interface {
327 Unmarshal([]byte) error
328}
329
330var legacyProtoMethods = &piface.Methods{
331 Size: legacySize,
332 MarshalAppend: legacyMarshalAppend,
333 Unmarshal: legacyUnmarshal,
334}
335
336func legacySize(m protoreflect.Message, opts piface.MarshalOptions) int {
337 b, _ := legacyMarshalAppend(nil, m, opts)
338 return len(b)
339}
340
341func legacyMarshalAppend(b []byte, m protoreflect.Message, opts piface.MarshalOptions) ([]byte, error) {
342 v := m.(unwrapper).protoUnwrap()
343 marshaler, ok := v.(legacyMarshaler)
344 if !ok {
345 return nil, errors.New("%T does not implement Marshal", v)
346 }
347 out, err := marshaler.Marshal()
348 if b != nil {
349 out = append(b, out...)
350 }
351 return out, err
352}
353
354func legacyUnmarshal(b []byte, m protoreflect.Message, opts piface.UnmarshalOptions) error {
355 v := m.(unwrapper).protoUnwrap()
356 unmarshaler, ok := v.(legacyUnmarshaler)
357 if !ok {
358 return errors.New("%T does not implement Marshal", v)
359 }
360 return unmarshaler.Unmarshal(b)
361}
362
363// aberrantMessageType implements MessageType for all types other than pointer-to-struct.
364type aberrantMessageType struct {
365 t reflect.Type
366}
367
368func (mt aberrantMessageType) New() pref.Message {
369 return aberrantMessage{reflect.Zero(mt.t)}
370}
371func (mt aberrantMessageType) Zero() pref.Message {
372 return aberrantMessage{reflect.Zero(mt.t)}
373}
374func (mt aberrantMessageType) GoType() reflect.Type {
375 return mt.t
376}
377func (mt aberrantMessageType) Descriptor() pref.MessageDescriptor {
378 return LegacyLoadMessageDesc(mt.t)
379}
380
381// aberrantMessage implements Message for all types other than pointer-to-struct.
382//
383// When the underlying type implements legacyMarshaler or legacyUnmarshaler,
384// the aberrant Message can be marshaled or unmarshaled. Otherwise, there is
385// not much that can be done with values of this type.
386type aberrantMessage struct {
387 v reflect.Value
388}
389
390func (m aberrantMessage) ProtoReflect() pref.Message {
391 return m
392}
393
394func (m aberrantMessage) Descriptor() pref.MessageDescriptor {
395 return LegacyLoadMessageDesc(m.v.Type())
396}
397func (m aberrantMessage) Type() pref.MessageType {
398 return aberrantMessageType{m.v.Type()}
399}
400func (m aberrantMessage) New() pref.Message {
401 return aberrantMessage{reflect.Zero(m.v.Type())}
402}
403func (m aberrantMessage) Interface() pref.ProtoMessage {
404 return m
405}
406func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
407}
408func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
409 panic("invalid field descriptor")
410}
411func (m aberrantMessage) Clear(pref.FieldDescriptor) {
412 panic("invalid field descriptor")
413}
414func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value {
415 panic("invalid field descriptor")
416}
417func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
418 panic("invalid field descriptor")
419}
420func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
421 panic("invalid field descriptor")
422}
423func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
424 panic("invalid field descriptor")
425}
426func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
427 panic("invalid oneof descriptor")
428}
429func (m aberrantMessage) GetUnknown() pref.RawFields {
430 return nil
431}
432func (m aberrantMessage) SetUnknown(pref.RawFields) {
433 // SetUnknown discards its input on messages which don't support unknown field storage.
434}
435func (m aberrantMessage) ProtoMethods() *piface.Methods {
436 return legacyProtoMethods
437}
438func (m aberrantMessage) protoUnwrap() interface{} {
439 return m.v.Interface()
440}