Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Naming conflict when dependency is named "Create" #3069

Closed
richarddd opened this issue Nov 28, 2021 · 1 comment
Closed

[Bug] Naming conflict when dependency is named "Create" #3069

richarddd opened this issue Nov 28, 2021 · 1 comment

Comments

@richarddd
Copy link

Dagger generates invalid code when an injected dependency is named "Create.java" or "Create.kt"

  public static ExampleComponent create() {
    return new Builder().build();
  }

  private Create create() {
    return new Create(ExampleModule_ProvideExampleDependencyFactory.provideExampleDependency(exampleModule));
  }

'create()' is already defined ...

The private method should be renamed to something other than our dependencies to avoid the name conflict.

Reproducable repo here:
https://github.com/richarddd/dagger-name-conflict

It could be sovled by postfixing the method with a hash value like hex(fletcher32(canonicalName)) or by adding a dagger prefix. Examples:

private Create daggerCreateCreateDependency() {...}
private Create createb886c8a7() {...}
@JakeWharton
Copy link

Using NameAllocator for the method names would solve it as well.

copybara-service bot pushed a commit that referenced this issue Jan 21, 2022
…e() factory method on the component.

Fixes #3069.

RELNOTES=Fix #3069 where a class named "Create" could cause a conflict.
PiperOrigin-RevId: 419019730
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants