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

Fixes self-loop when generated implementation of an assisted factory method calls a generated component method with the same name. #2362

Merged
merged 0 commits into from
Feb 6, 2021

Conversation

copybara-service[bot]
Copy link

Fixes self-loop when generated implementation of an assisted factory method calls a generated component method with the same name.

The problem exists in FastInit mode, where the private method name can conflict with the factory method name:

final class DaggerMyComponent implements MyComponent {
  @Override
  public FooFactory fooFactory() {
    return new FooFactory() {
      @Override
      public Foo foo() {
        return foo();  // This calls factory method rather than component method
      }
    };
  }

  private Foo foo() {
    return new Foo(getDep());
  }
}

The fix is to reference outer component when calling the private method within the anonymous class.

Fixes #2359

RELNOTES=Fixes #2359: Fixes self-loop when generated implementation of an assisted factory method calls a generated component method with the same name.

@google-cla google-cla bot added the cla: yes label Feb 6, 2021
@copybara-service copybara-service bot merged commit e2c9a9a into master Feb 6, 2021
@copybara-service copybara-service bot deleted the test_355887899 branch February 6, 2021 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AssistedInject] Dagger generates code that calls an infinite loop
0 participants