bind(X.class).annotatedWith(A1.class).to(XImpl1.class).in(Scopes.SINGLETON);
bind(X.class).annotatedWith(A2.class).to(XImpl2.class).in(Scopes.SINGLETON);
Then you can:
@Inject @A1 X x1;
@Inject @A2 X x2;
You can't use @Singleton as an annotation in the Impl's class
definition because you need to define the singleton scope separately
per annotation.
Sam
I think it would require information that only Guice knows; details
about the injection spot. Like, I could do it with a Provider that
somehow had access to all the annotations of the field being injected,
but I don't think that's possible. Perhaps it'd require a
modification to Guice: would someone with knowledge of Guice internals
verify?