dagger icon indicating copy to clipboard operation
dagger copied to clipboard

Bad error message for missing Set provider

Open norrisboyd opened this issue 10 years ago • 0 comments

Compiling the following class:

import dagger.ObjectGraph;
import dagger.Module;
import dagger.Provides;
import java.util.Set;

public class BadErrorMessage {
  @Module
  public static class MyModule {
    @Provides Long provideSum(Set<Integer> integers) {
      long sum = 0; 
      for (int i : integers) {
        sum += i;
      }
      return sum;
    } 
  } 

  public static void main(String[] args) {
    ObjectGraph graph = ObjectGraph.create(MyModule.class);
    System.out.println("sum = " + graph.get(Long.class).valueOf());
  }
}

Results in the error message:

BadErrorMessage.java:8: error: java.util.Set<java.lang.Integer> is a generic class or an array and can only be bound with concrete type parameter(s) in a @Provides method. required by provideSum(java.util.Set<java.lang.Integer>) for BadErrorMessage.MyModule
  public static class MyModule {
                ^
1 error

However,

Set<Integer>

is not a generic class or array.

norrisboyd avatar Aug 19 '14 19:08 norrisboyd