blob: dbc99edd8bc44048f31ce15fd53f68aac4128224 [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 Neilc7f2bee2019-11-06 15:29:05 -080055
56 // We have no way to tell whether the type's Marshal method
57 // supports deterministic serialization or not, but this
58 // preserves the v1 implementation's behavior of always
59 // calling Marshal methods when present.
60 mi.methods.Flags |= piface.SupportMarshalDeterministic
Damien Neil37ef6912019-09-25 16:51:15 -070061 }
Damien Neil47d58932019-09-30 15:34:27 -070062 if _, ok := v.(legacyUnmarshaler); ok {
63 mi.methods.Unmarshal = legacyUnmarshal
Damien Neil37ef6912019-09-25 16:51:15 -070064 }
65
Damien Neil16163b42019-08-06 15:43:25 -070066 if mi, ok := legacyMessageTypeCache.LoadOrStore(t, mi); ok {
67 return mi.(*MessageInfo)
Joe Tsaib9365042019-03-19 14:14:29 -070068 }
Damien Neil16163b42019-08-06 15:43:25 -070069 return mi
Joe Tsaice6edd32018-10-19 16:27:46 -070070}
71
Joe Tsaid8881392019-06-06 13:01:53 -070072var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
Joe Tsai90fe9962018-10-18 11:06:29 -070073
Joe Tsai21ade492019-05-22 13:42:54 -040074// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
Joe Tsaice6edd32018-10-19 16:27:46 -070075// which must be a *struct kind and not implement the v2 API already.
Joe Tsai35ec98f2019-03-25 14:41:32 -070076//
77// This is exported for testing purposes.
Joe Tsai21ade492019-05-22 13:42:54 -040078func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
Joe Tsaiea5ada12019-09-04 22:41:40 -070079 return legacyLoadMessageDesc(t, "")
80}
81func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai90fe9962018-10-18 11:06:29 -070082 // Fast-path: check if a MessageDescriptor is cached for this concrete type.
Joe Tsai21ade492019-05-22 13:42:54 -040083 if mi, ok := legacyMessageDescCache.Load(t); ok {
Joe Tsai90fe9962018-10-18 11:06:29 -070084 return mi.(pref.MessageDescriptor)
85 }
86
Joe Tsaid8881392019-06-06 13:01:53 -070087 // Slow-path: initialize MessageDescriptor from the raw descriptor.
Damien Neil47d58932019-09-30 15:34:27 -070088 mv := reflect.Zero(t).Interface()
Joe Tsai90fe9962018-10-18 11:06:29 -070089 if _, ok := mv.(pref.ProtoMessage); ok {
90 panic(fmt.Sprintf("%v already implements proto.Message", t))
91 }
Joe Tsaid8881392019-06-06 13:01:53 -070092 mdV1, ok := mv.(messageV1)
93 if !ok {
Joe Tsaiea5ada12019-09-04 22:41:40 -070094 return aberrantLoadMessageDesc(t, name)
Joe Tsaid8881392019-06-06 13:01:53 -070095 }
96 b, idxs := mdV1.Descriptor()
Joe Tsai90fe9962018-10-18 11:06:29 -070097
Joe Tsaid8881392019-06-06 13:01:53 -070098 md := legacyLoadFileDesc(b).Messages().Get(idxs[0])
99 for _, i := range idxs[1:] {
100 md = md.Messages().Get(i)
Joe Tsai90fe9962018-10-18 11:06:29 -0700101 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700102 if name != "" && md.FullName() != name {
103 panic(fmt.Sprintf("mismatching message name: got %v, want %v", md.FullName(), name))
104 }
Joe Tsaid8881392019-06-06 13:01:53 -0700105 if md, ok := legacyMessageDescCache.LoadOrStore(t, md); ok {
106 return md.(protoreflect.MessageDescriptor)
Joe Tsai90fe9962018-10-18 11:06:29 -0700107 }
Joe Tsaid8881392019-06-06 13:01:53 -0700108 return md
Joe Tsai90fe9962018-10-18 11:06:29 -0700109}
Joe Tsai851185d2019-07-01 13:45:52 -0700110
Joe Tsai32e8a522019-07-02 10:51:24 -0700111var (
112 aberrantMessageDescLock sync.Mutex
113 aberrantMessageDescCache map[reflect.Type]protoreflect.MessageDescriptor
114)
Joe Tsai851185d2019-07-01 13:45:52 -0700115
Damien Neil47d58932019-09-30 15:34:27 -0700116// aberrantLoadMessageDesc returns an MessageDescriptor derived from the Go type,
Joe Tsai851185d2019-07-01 13:45:52 -0700117// which must not implement protoreflect.ProtoMessage or messageV1.
118//
119// This is a best-effort derivation of the message descriptor using the protobuf
120// tags on the struct fields.
Joe Tsaiea5ada12019-09-04 22:41:40 -0700121func aberrantLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai32e8a522019-07-02 10:51:24 -0700122 aberrantMessageDescLock.Lock()
123 defer aberrantMessageDescLock.Unlock()
124 if aberrantMessageDescCache == nil {
125 aberrantMessageDescCache = make(map[reflect.Type]protoreflect.MessageDescriptor)
126 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700127 return aberrantLoadMessageDescReentrant(t, name)
Joe Tsai32e8a522019-07-02 10:51:24 -0700128}
Joe Tsaiea5ada12019-09-04 22:41:40 -0700129func aberrantLoadMessageDescReentrant(t reflect.Type, name pref.FullName) pref.MessageDescriptor {
Joe Tsai851185d2019-07-01 13:45:52 -0700130 // Fast-path: check if an MessageDescriptor is cached for this concrete type.
Joe Tsai32e8a522019-07-02 10:51:24 -0700131 if md, ok := aberrantMessageDescCache[t]; ok {
132 return md
Joe Tsai851185d2019-07-01 13:45:52 -0700133 }
134
Joe Tsai851185d2019-07-01 13:45:52 -0700135 // Slow-path: construct a descriptor from the Go struct type (best-effort).
Joe Tsai32e8a522019-07-02 10:51:24 -0700136 // Cache the MessageDescriptor early on so that we can resolve internal
137 // cyclic references.
138 md := &filedesc.Message{L2: new(filedesc.MessageL2)}
Damien Neil47d58932019-09-30 15:34:27 -0700139 md.L0.FullName = aberrantDeriveMessageName(t, name)
Joe Tsai851185d2019-07-01 13:45:52 -0700140 md.L0.ParentFile = filedesc.SurrogateProto2
Joe Tsai32e8a522019-07-02 10:51:24 -0700141 aberrantMessageDescCache[t] = md
Joe Tsai851185d2019-07-01 13:45:52 -0700142
Damien Neil47d58932019-09-30 15:34:27 -0700143 if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
144 return md
145 }
146
Joe Tsai851185d2019-07-01 13:45:52 -0700147 // Try to determine if the message is using proto3 by checking scalars.
148 for i := 0; i < t.Elem().NumField(); i++ {
149 f := t.Elem().Field(i)
150 if tag := f.Tag.Get("protobuf"); tag != "" {
151 switch f.Type.Kind() {
152 case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String:
153 md.L0.ParentFile = filedesc.SurrogateProto3
154 }
155 for _, s := range strings.Split(tag, ",") {
156 if s == "proto3" {
157 md.L0.ParentFile = filedesc.SurrogateProto3
158 }
159 }
160 }
161 }
162
163 // Obtain a list of oneof wrapper types.
164 var oneofWrappers []reflect.Type
165 if fn, ok := t.MethodByName("XXX_OneofFuncs"); ok {
166 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[3]
167 for _, v := range vs.Interface().([]interface{}) {
168 oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
169 }
170 }
171 if fn, ok := t.MethodByName("XXX_OneofWrappers"); ok {
172 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0]
173 for _, v := range vs.Interface().([]interface{}) {
174 oneofWrappers = append(oneofWrappers, reflect.TypeOf(v))
175 }
176 }
177
178 // Obtain a list of the extension ranges.
179 if fn, ok := t.MethodByName("ExtensionRangeArray"); ok {
180 vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0]
181 for i := 0; i < vs.Len(); i++ {
182 v := vs.Index(i)
183 md.L2.ExtensionRanges.List = append(md.L2.ExtensionRanges.List, [2]pref.FieldNumber{
184 pref.FieldNumber(v.FieldByName("Start").Int()),
185 pref.FieldNumber(v.FieldByName("End").Int() + 1),
186 })
187 md.L2.ExtensionRangeOptions = append(md.L2.ExtensionRangeOptions, nil)
188 }
189 }
190
191 // Derive the message fields by inspecting the struct fields.
192 for i := 0; i < t.Elem().NumField(); i++ {
193 f := t.Elem().Field(i)
194 if tag := f.Tag.Get("protobuf"); tag != "" {
195 tagKey := f.Tag.Get("protobuf_key")
196 tagVal := f.Tag.Get("protobuf_val")
197 aberrantAppendField(md, f.Type, tag, tagKey, tagVal)
198 }
199 if tag := f.Tag.Get("protobuf_oneof"); tag != "" {
200 n := len(md.L2.Oneofs.List)
201 md.L2.Oneofs.List = append(md.L2.Oneofs.List, filedesc.Oneof{})
202 od := &md.L2.Oneofs.List[n]
203 od.L0.FullName = md.FullName().Append(pref.Name(tag))
204 od.L0.ParentFile = md.L0.ParentFile
205 od.L0.Parent = md
206 od.L0.Index = n
207
208 for _, t := range oneofWrappers {
209 if t.Implements(f.Type) {
210 f := t.Elem().Field(0)
211 if tag := f.Tag.Get("protobuf"); tag != "" {
212 aberrantAppendField(md, f.Type, tag, "", "")
213 fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1]
214 fd.L1.ContainingOneof = od
215 od.L1.Fields.List = append(od.L1.Fields.List, fd)
216 }
217 }
218 }
219 }
220 }
221
Joe Tsai851185d2019-07-01 13:45:52 -0700222 return md
223}
224
Joe Tsaiea5ada12019-09-04 22:41:40 -0700225func aberrantDeriveMessageName(t reflect.Type, name pref.FullName) pref.FullName {
226 if name.IsValid() {
227 return name
228 }
Joe Tsaie87cf532019-09-10 12:20:00 -0700229 func() {
230 defer func() { recover() }() // swallow possible nil panics
Damien Neil47d58932019-09-30 15:34:27 -0700231 if m, ok := reflect.Zero(t).Interface().(interface{ XXX_MessageName() string }); ok {
Joe Tsaie87cf532019-09-10 12:20:00 -0700232 name = pref.FullName(m.XXX_MessageName())
Joe Tsaiea5ada12019-09-04 22:41:40 -0700233 }
Joe Tsaie87cf532019-09-10 12:20:00 -0700234 }()
235 if name.IsValid() {
236 return name
Joe Tsaiea5ada12019-09-04 22:41:40 -0700237 }
Damien Neil47d58932019-09-30 15:34:27 -0700238 if t.Kind() == reflect.Ptr {
239 t = t.Elem()
240 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700241 return aberrantDeriveFullName(t)
242}
243
Joe Tsai851185d2019-07-01 13:45:52 -0700244func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey, tagVal string) {
245 t := goType
246 isOptional := t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct
247 isRepeated := t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8
248 if isOptional || isRepeated {
249 t = t.Elem()
250 }
251 fd := ptag.Unmarshal(tag, t, placeholderEnumValues{}).(*filedesc.Field)
252
253 // Append field descriptor to the message.
254 n := len(md.L2.Fields.List)
255 md.L2.Fields.List = append(md.L2.Fields.List, *fd)
256 fd = &md.L2.Fields.List[n]
257 fd.L0.FullName = md.FullName().Append(fd.Name())
258 fd.L0.ParentFile = md.L0.ParentFile
259 fd.L0.Parent = md
260 fd.L0.Index = n
261
262 if fd.L1.IsWeak || fd.L1.HasPacked {
263 fd.L1.Options = func() pref.ProtoMessage {
264 opts := descopts.Field.ProtoReflect().New()
265 if fd.L1.IsWeak {
Joe Tsai84177c92019-09-17 13:38:48 -0700266 opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
Joe Tsai851185d2019-07-01 13:45:52 -0700267 }
268 if fd.L1.HasPacked {
Joe Tsai84177c92019-09-17 13:38:48 -0700269 opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked))
Joe Tsai851185d2019-07-01 13:45:52 -0700270 }
271 return opts.Interface()
272 }
273 }
274
275 // Populate Enum and Message.
276 if fd.Enum() == nil && fd.Kind() == pref.EnumKind {
277 switch v := reflect.Zero(t).Interface().(type) {
278 case pref.Enum:
279 fd.L1.Enum = v.Descriptor()
280 default:
281 fd.L1.Enum = LegacyLoadEnumDesc(t)
282 }
283 }
284 if fd.Message() == nil && (fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind) {
285 switch v := reflect.Zero(t).Interface().(type) {
286 case pref.ProtoMessage:
287 fd.L1.Message = v.ProtoReflect().Descriptor()
Joe Tsai32e8a522019-07-02 10:51:24 -0700288 case messageV1:
289 fd.L1.Message = LegacyLoadMessageDesc(t)
Joe Tsai851185d2019-07-01 13:45:52 -0700290 default:
291 if t.Kind() == reflect.Map {
292 n := len(md.L1.Messages.List)
293 md.L1.Messages.List = append(md.L1.Messages.List, filedesc.Message{L2: new(filedesc.MessageL2)})
294 md2 := &md.L1.Messages.List[n]
Joe Tsai97a87392019-07-07 01:49:59 -0700295 md2.L0.FullName = md.FullName().Append(pref.Name(strs.MapEntryName(string(fd.Name()))))
Joe Tsai851185d2019-07-01 13:45:52 -0700296 md2.L0.ParentFile = md.L0.ParentFile
297 md2.L0.Parent = md
298 md2.L0.Index = n
299
300 md2.L2.IsMapEntry = true
301 md2.L2.Options = func() pref.ProtoMessage {
302 opts := descopts.Message.ProtoReflect().New()
Joe Tsai84177c92019-09-17 13:38:48 -0700303 opts.Set(opts.Descriptor().Fields().ByName("map_entry"), protoreflect.ValueOfBool(true))
Joe Tsai851185d2019-07-01 13:45:52 -0700304 return opts.Interface()
305 }
306
307 aberrantAppendField(md2, t.Key(), tagKey, "", "")
308 aberrantAppendField(md2, t.Elem(), tagVal, "", "")
309
310 fd.L1.Message = md2
311 break
312 }
Joe Tsaiea5ada12019-09-04 22:41:40 -0700313 fd.L1.Message = aberrantLoadMessageDescReentrant(t, "")
Joe Tsai851185d2019-07-01 13:45:52 -0700314 }
315 }
316}
317
318type placeholderEnumValues struct {
319 protoreflect.EnumValueDescriptors
320}
321
322func (placeholderEnumValues) ByNumber(n pref.EnumNumber) pref.EnumValueDescriptor {
323 return filedesc.PlaceholderEnumValue(pref.FullName(fmt.Sprintf("UNKNOWN_%d", n)))
324}
Damien Neil47d58932019-09-30 15:34:27 -0700325
326// legacyMarshaler is the proto.Marshaler interface superseded by protoiface.Methoder.
327type legacyMarshaler interface {
328 Marshal() ([]byte, error)
329}
330
331// legacyUnmarshaler is the proto.Unmarshaler interface superseded by protoiface.Methoder.
332type legacyUnmarshaler interface {
333 Unmarshal([]byte) error
334}
335
336var legacyProtoMethods = &piface.Methods{
337 Size: legacySize,
338 MarshalAppend: legacyMarshalAppend,
339 Unmarshal: legacyUnmarshal,
Damien Neilc7f2bee2019-11-06 15:29:05 -0800340
341 // We have no way to tell whether the type's Marshal method
342 // supports deterministic serialization or not, but this
343 // preserves the v1 implementation's behavior of always
344 // calling Marshal methods when present.
345 Flags: piface.SupportMarshalDeterministic,
Damien Neil47d58932019-09-30 15:34:27 -0700346}
347
348func legacySize(m protoreflect.Message, opts piface.MarshalOptions) int {
349 b, _ := legacyMarshalAppend(nil, m, opts)
350 return len(b)
351}
352
353func legacyMarshalAppend(b []byte, m protoreflect.Message, opts piface.MarshalOptions) ([]byte, error) {
354 v := m.(unwrapper).protoUnwrap()
355 marshaler, ok := v.(legacyMarshaler)
356 if !ok {
357 return nil, errors.New("%T does not implement Marshal", v)
358 }
359 out, err := marshaler.Marshal()
360 if b != nil {
361 out = append(b, out...)
362 }
363 return out, err
364}
365
366func legacyUnmarshal(b []byte, m protoreflect.Message, opts piface.UnmarshalOptions) error {
367 v := m.(unwrapper).protoUnwrap()
368 unmarshaler, ok := v.(legacyUnmarshaler)
369 if !ok {
370 return errors.New("%T does not implement Marshal", v)
371 }
372 return unmarshaler.Unmarshal(b)
373}
374
375// aberrantMessageType implements MessageType for all types other than pointer-to-struct.
376type aberrantMessageType struct {
377 t reflect.Type
378}
379
380func (mt aberrantMessageType) New() pref.Message {
381 return aberrantMessage{reflect.Zero(mt.t)}
382}
383func (mt aberrantMessageType) Zero() pref.Message {
384 return aberrantMessage{reflect.Zero(mt.t)}
385}
386func (mt aberrantMessageType) GoType() reflect.Type {
387 return mt.t
388}
389func (mt aberrantMessageType) Descriptor() pref.MessageDescriptor {
390 return LegacyLoadMessageDesc(mt.t)
391}
392
393// aberrantMessage implements Message for all types other than pointer-to-struct.
394//
395// When the underlying type implements legacyMarshaler or legacyUnmarshaler,
396// the aberrant Message can be marshaled or unmarshaled. Otherwise, there is
397// not much that can be done with values of this type.
398type aberrantMessage struct {
399 v reflect.Value
400}
401
402func (m aberrantMessage) ProtoReflect() pref.Message {
403 return m
404}
405
406func (m aberrantMessage) Descriptor() pref.MessageDescriptor {
407 return LegacyLoadMessageDesc(m.v.Type())
408}
409func (m aberrantMessage) Type() pref.MessageType {
410 return aberrantMessageType{m.v.Type()}
411}
412func (m aberrantMessage) New() pref.Message {
413 return aberrantMessage{reflect.Zero(m.v.Type())}
414}
415func (m aberrantMessage) Interface() pref.ProtoMessage {
416 return m
417}
418func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
419}
420func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
421 panic("invalid field descriptor")
422}
423func (m aberrantMessage) Clear(pref.FieldDescriptor) {
424 panic("invalid field descriptor")
425}
426func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value {
427 panic("invalid field descriptor")
428}
429func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
430 panic("invalid field descriptor")
431}
432func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
433 panic("invalid field descriptor")
434}
435func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
436 panic("invalid field descriptor")
437}
438func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
439 panic("invalid oneof descriptor")
440}
441func (m aberrantMessage) GetUnknown() pref.RawFields {
442 return nil
443}
444func (m aberrantMessage) SetUnknown(pref.RawFields) {
445 // SetUnknown discards its input on messages which don't support unknown field storage.
446}
447func (m aberrantMessage) ProtoMethods() *piface.Methods {
448 return legacyProtoMethods
449}
450func (m aberrantMessage) protoUnwrap() interface{} {
451 return m.v.Interface()
452}