internal/impl: make resolverOnly explicitly implement file resolver

The resolverOnly type embeds a *protoregistry.Files and overrides one of
of its methods. When that method was renamed (Register -> RegisterFile),
the resolverOnly type continued to compile but no longer overrode the
desired method.

Update the method name, and change this type to explicitly forward
methods to the underlying *protoregistry.Files to catch errors of this
nature in the future.

Change-Id: I09a529034b6e2f310977bc635288fa15ce14cc7e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/205242
Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
Damien Neil 2019-11-04 15:30:28 -08:00
parent a0a54b8005
commit a2684f4b8a

View File

@ -67,7 +67,15 @@ func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor {
}
type resolverOnly struct {
*protoregistry.Files
reg *protoregistry.Files
}
func (resolverOnly) Register(protoreflect.FileDescriptor) error { return nil }
func (r resolverOnly) FindFileByPath(path string) (protoreflect.FileDescriptor, error) {
return r.reg.FindFileByPath(path)
}
func (r resolverOnly) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) {
return r.reg.FindDescriptorByName(name)
}
func (resolverOnly) RegisterFile(protoreflect.FileDescriptor) error {
return nil
}