diff --git a/internal/impl/legacy_message.go b/internal/impl/legacy_message.go index ff1c69bc..6c522848 100644 --- a/internal/impl/legacy_message.go +++ b/internal/impl/legacy_message.go @@ -202,10 +202,14 @@ func aberrantDeriveMessageName(t reflect.Type, name pref.FullName) pref.FullName if name.IsValid() { return name } - if m, ok := reflect.New(t).Interface().(interface{ XXX_MessageName() string }); ok { - if name := pref.FullName(m.XXX_MessageName()); name.IsValid() { - return name + func() { + defer func() { recover() }() // swallow possible nil panics + if m, ok := reflect.New(t).Interface().(interface{ XXX_MessageName() string }); ok { + name = pref.FullName(m.XXX_MessageName()) } + }() + if name.IsValid() { + return name } return aberrantDeriveFullName(t) }