Skip to content

Commit

Permalink
Correct type_resolver_util to set syntax=proto3 instead of syntax=pro…
Browse files Browse the repository at this point in the history
…to2 on proto3 files.

PiperOrigin-RevId: 600473754
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 22, 2024
1 parent 71b0b4e commit 040dde7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/google/protobuf/util/type_resolver_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ void ConvertFieldDescriptor(absl::string_view url_prefix,
}

Syntax ConvertSyntax(Edition edition) {
if (edition >= Edition::EDITION_2023) {
return Syntax::SYNTAX_EDITIONS;
switch (edition) {
case Edition::EDITION_PROTO2:
return Syntax::SYNTAX_PROTO2;
case Edition::EDITION_PROTO3:
return Syntax::SYNTAX_PROTO3;
default:
return Syntax::SYNTAX_EDITIONS;
}
// TODO This should propagate proto3 as expected.
return Syntax::SYNTAX_PROTO2;
}

void ConvertEnumDescriptor(const EnumDescriptor& descriptor, Enum* enum_type) {
Expand Down
3 changes: 1 addition & 2 deletions src/google/protobuf/util/type_resolver_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ TEST_F(DescriptorPoolTypeResolverSyntaxTest, SyntaxProto3) {
Type type;
ASSERT_TRUE(
resolver_->ResolveMessageType(GetTypeUrl("test.MyMessage"), &type).ok());
// TODO This should be proto3.
EXPECT_EQ(type.syntax(), Syntax::SYNTAX_PROTO2);
EXPECT_EQ(type.syntax(), Syntax::SYNTAX_PROTO3);
EXPECT_EQ(type.edition(), "");
}

Expand Down

0 comments on commit 040dde7

Please sign in to comment.