google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

Just-in-time bindings for TypeLiteral<T> to undo erasure #270

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Suppose we supported just-in-time bindings for instances of TypeLiteral:
   @Inject TypeLiteral<String> stringType;
   @Inject List<Map<Integer, Short>> listOfMapType;
In this case, we'd inject the TypeLiteral.get(String.class) and 
TypeLiteral.get(Types.mapOf(Integer.class, String.class)) respectively. This 
requires a special case 
for injecting TypeLiterals. It gets interesting is when we combine this type 
parameter matching. 
Consider:
  class Foo<T> {
    @Inject TypeLiteral<T> myTypeParameter;
    @Inject TypeLiteral<Foo<T>> myRuntimeType;
  }
For example, if I had a Foo<String>, my injected type parameter would be a 
TypeLiteral<String>. A nice value add, without much complexity.

Original issue reported on code.google.com by limpbizkit on 10 Nov 2008 at 8:33

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 30 Dec 2008 at 11:45