internal/impl: handle irregular messages implementing proto.Message
When encountering a type that does not have a MessageInfo, don't assume
that it's a legacy message that doesn't implement proto.Message. Add a
set of test messages exercising this case (panics prior to the
internal/impl change).
Change-Id: Ic1ec5ecfbe92278fbef44284ff52a0e0622a158c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/182477
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/cmd/generate-protos/main.go b/internal/cmd/generate-protos/main.go
index 3ab6c30..cfc8c8a 100644
--- a/internal/cmd/generate-protos/main.go
+++ b/internal/cmd/generate-protos/main.go
@@ -105,10 +105,11 @@
path string
grpcPlugin bool
annotateFor map[string]bool
+ exclude map[string]bool
}{
{path: "cmd/protoc-gen-go/testdata", annotateFor: map[string]bool{"annotations/annotations.proto": true}},
{path: "cmd/protoc-gen-go-grpc/testdata", grpcPlugin: true},
- {path: "internal/testprotos"},
+ {path: "internal/testprotos", exclude: map[string]bool{"irregular/irregular.proto": true}},
{path: "encoding/testprotos"},
{path: "reflect/protoregistry/testprotos"},
}
@@ -128,6 +129,10 @@
check(err)
subDirs[filepath.Dir(relPath)] = true
+ if d.exclude[filepath.ToSlash(relPath)] {
+ return nil
+ }
+
// Emit a .meta file for certain files.
var opts string
if d.annotateFor[filepath.ToSlash(relPath)] {