On 30 Dec 2011, at 02:58, Russ Milliken wrote: > FWIW, that's the only way I've been able to get it to work (class cast and > warning).
Yep, I forgot to add the cast - the reason you need it is because this approach uses: Key<?> Key.get(Type type, Annotation annotation) and the compiler can't infer the Key's type argument from the raw "java.lang.reflect.Type" instance (it has no generic signature). It's the opposite of the usual erasure problem - here the generic parameters are available at runtime, but not at compile time :) > -Russ > > On Thu, Dec 29, 2011 at 9:41 PM, glenviewjeff <[email protected]> wrote: > Awesome Stuart, thanks so much! I was able to get it to execute correctly, > albeit with an unchecked cast and warning as below. Do you (or does anyone > else) know of any way around this? > > final Key<Set<T>> multibinderKey = (Key<Set<T>>) Key.get(Types.setOf( > superClass ), annotation); > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-guice/-/qYnPiVt-cqoJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
