Skip to content

Commit d66c759

Browse files
1e0ngcopybara-github
authored andcommitted
Remove unnecessary cast to Builder in generated Java lite code. (#10781)
Fixes #5139 Previously the fix #5247 has removed unnecessary cast to Builder in generated Java code, and the current PR is doing a similar one for Java lite code. After this PR, both Java and Java lite code won't have an unnecessary cast to Builder, thus #5139 will be fixed. This change simply removed those casts to Builder for 2 methods, and the reason it will work is: DEFAULT_INSTANCE.createBuilder method is defined in the superclass, and the return value is a generic value which is exactly the Builder class passed in. Closes #10781 COPYBARA_INTEGRATE_REVIEW=#10781 from 1e0ng:main e8f9c98 FUTURE_COPYBARA_INTEGRATE_REVIEW=#10781 from 1e0ng:main e8f9c98 PiperOrigin-RevId: 532797271
1 parent e285d3e commit d66c759

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/google/protobuf/compiler/java/message_lite.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
699699
" return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
700700
"}\n"
701701
"public static Builder newBuilder($classname$ prototype) {\n"
702-
" return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n"
702+
" return DEFAULT_INSTANCE.createBuilder(prototype);\n"
703703
"}\n"
704704
"\n",
705705
"classname", name_resolver_->GetImmutableClassName(descriptor_));

0 commit comments

Comments
 (0)