Skip to content

Commit

Permalink
Rename init() method in generated Activity to avoid conflict with use…
Browse files Browse the repository at this point in the history
…r method of same name.

Fixes #2456

RELNOTES="Fix #2456: Rename init() method in generated Activity to avoid conflict with user method of same name."
PiperOrigin-RevId: 361220626
  • Loading branch information
danysantiago authored and Dagger Team committed Mar 5, 2021
1 parent 7e0abd6 commit 1c66033
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public void generate() throws IOException {
Processors.addGeneratedAnnotation(builder, env, getClass());

Generators.copyConstructors(
metadata.baseElement(), CodeBlock.builder().addStatement("init()").build(), builder);
metadata.baseElement(),
CodeBlock.builder().addStatement("_initHiltInternal()").build(),
builder);
builder.addMethod(init());

metadata.baseElement().getTypeParameters().stream()
Expand Down Expand Up @@ -88,7 +90,7 @@ public void generate() throws IOException {
// });
// }
private MethodSpec init() {
return MethodSpec.methodBuilder("init")
return MethodSpec.methodBuilder("_initHiltInternal")
.addModifiers(Modifier.PRIVATE)
.addStatement(
"addOnContextAvailableListener($L)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void copyConstructorParametersCopiesExternalNullables() {
" @Nullable String androidxNullable,",
" @javax.annotation.Nullable String javaxNullable) {",
" super(supportNullable, androidxNullable, javaxNullable);",
" init();",
" _initHiltInternal();",
" }",
"}"));
}
Expand Down

0 comments on commit 1c66033

Please sign in to comment.