diff --git a/src/google/protobuf/compiler/java/generator_unittest.cc b/src/google/protobuf/compiler/java/generator_unittest.cc index 8552840beebb0..55725d3b3d0f9 100644 --- a/src/google/protobuf/compiler/java/generator_unittest.cc +++ b/src/google/protobuf/compiler/java/generator_unittest.cc @@ -65,6 +65,28 @@ TEST_F(JavaGeneratorTest, BasicError) { "foo.proto:4:7: Expected \"required\", \"optional\", or \"repeated\""); } +TEST_F(JavaGeneratorTest, ImplicitPresenceLegacyClosedEnumDisallowed) { + CreateTempFile("foo.proto", + R"schema( + edition = "2023"; + import "third_party/java/protobuf/java_features.proto"; + option features.field_presence = IMPLICIT; + enum Bar { + AAA = 0; + } + message Foo { + Bar bar = 1 [features.(pb.java).legacy_closed_enum = true]; + } + )schema"); + + RunProtoc( + "protocol_compiler --proto_path=$tmpdir --java_out=$tmpdir foo.proto"); + + ExpectErrorSubstring( + "foo.proto: Field Foo.bar has a closed enum type with implicit " + "presence."); +} + } // namespace } // namespace java