I don't think we have the full generics supported for ProviderMethods yet.

We'll need to consider incorporating mcculls patch, and perhaps a full TypeResolver class...

git-svn-id: https://google-guice.googlecode.com/svn/trunk@533 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/test/com/google/inject/ProviderMethodsTest.java b/test/com/google/inject/ProviderMethodsTest.java
index 500f64b..5048f85 100644
--- a/test/com/google/inject/ProviderMethodsTest.java
+++ b/test/com/google/inject/ProviderMethodsTest.java
@@ -16,11 +16,15 @@
 
 package com.google.inject;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.inject.name.Named;
+import com.google.inject.name.Names;
+import com.google.inject.util.Types;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
+import java.util.Set;
 import junit.framework.TestCase;
 
 /**
@@ -175,4 +179,35 @@
   @Retention(RUNTIME)
   @BindingAnnotation @interface Blue {}
 
+  public void testGenericProviderMethods() {
+    ProvideTs<String> source = new ProvideTs<String>("A", "B") {};
+    Injector injector = Guice.createInjector(ProviderMethods.from(source));
+    
+    assertEquals("A", injector.getInstance(Key.get(String.class, Names.named("First"))));
+    assertEquals("B", injector.getInstance(Key.get(String.class, Names.named("First"))));
+    assertEquals(ImmutableSet.of("A", "B"),
+        injector.getInstance(Key.get(Types.setOf(String.class))));
+  }
+
+  abstract class ProvideTs<T> {
+    final T first;
+    final T second;
+
+    protected ProvideTs(T first, T second) {
+      this.first = first;
+      this.second = second;
+    }
+
+    @Named("First") @Provides T provideFirst() {
+      return first;
+    }
+
+    @Named("Second") @Provides T provideSecond() {
+      return second;
+    }
+
+    @Provides Set<T> provideBoth(@Named("First") T first, @Named("Second") T second) {
+      return ImmutableSet.of(first, second);
+    }
+  }
 }
\ No newline at end of file