Always missing required field if a message has required/closed enum.

PiperOrigin-RevId: 553905009
pull/13447/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 4bf423b2c1
commit c6810f1505
  1. 1
      src/google/protobuf/compiler/cpp/message.cc
  2. 11
      src/google/protobuf/unittest.proto

@ -68,6 +68,7 @@
#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
#include "google/protobuf/wire_format.h" #include "google/protobuf/wire_format.h"
#include "google/protobuf/wire_format_lite.h"
// Must be included last. // Must be included last.

@ -424,6 +424,15 @@ message TestNestedChildExtensionData {
optional TestChildExtensionData child = 2; optional TestChildExtensionData child = 2;
} }
// Required and closed enum fields are considered unknown fields if the value is
// not valid. We need to make sure it functions as expected.
message TestRequiredEnum {
// Required closed enum results in missing required fields.
required ForeignEnum required_enum = 1;
// A dummy optional field.
optional int32 a = 2;
}
// We have separate messages for testing required fields because it's // We have separate messages for testing required fields because it's
// annoying to have to fill in required fields in TestProto in order to // annoying to have to fill in required fields in TestProto in order to
// do anything with it. Note that we don't need to test every type of // do anything with it. Note that we don't need to test every type of
@ -496,6 +505,8 @@ message TestNestedRequiredForeign {
optional TestNestedRequiredForeign child = 1; optional TestNestedRequiredForeign child = 1;
optional TestRequiredForeign payload = 2; optional TestRequiredForeign payload = 2;
optional int32 dummy = 3; optional int32 dummy = 3;
// optional message to test required closed enum.
optional TestRequiredEnum required_enum = 5;
} }
// Test that we can use NestedMessage from outside TestAllTypes. // Test that we can use NestedMessage from outside TestAllTypes.

Loading…
Cancel
Save