A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations.


The problem

From the javadoc of FactoryModuleBuilder:

The types of the factory method’s parameters must be distinct. To use multiple parameters of the same type, use a named @Assisted annotation to disambiguate the parameters. The names must be applied to the factory method’s parameters:

public interface PaymentFactory {
   Payment create(
        @Assisted("startDate") Date startDate,
        @Assisted("dueDate") Date dueDate,
       Money amount);

…and to the concrete type’s constructor parameters:

public class RealPayment implements Payment {
   public RealPayment(
      CreditService creditService,
      AuthService authService,
       @Assisted("startDate") Date startDate,
       @Assisted("dueDate") Date dueDate,
       @Assisted Money amount) {


Suppress false positives by adding the suppression annotation @SuppressWarnings("GuiceAssistedParameters") to the enclosing element.