-
Notifications
You must be signed in to change notification settings - Fork 44
Added annotatedWithName to ScalaModule #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
def toProvider[TProvider <: Provider[_ <: T] : Manifest] = new ScalaScopedBindingBuilder { | ||
val self = outer.self toProvider typeLiteral[TProvider] | ||
} | ||
} | ||
|
||
trait ScalaAnnotatedBindingBuilder[T] extends ScalaLinkedBindingBuilder[T] | ||
with AnnotatedBindingBuilderProxy[T] { outer => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a style perspective, I'd prefer the trait definition to be on a single line. There are no other multi-line definitions in this project, and there are definitely longer lines (in this file even) than the ones created by squashing lines 109-110 and 118-119. So I suggest:
trait ScalaAnnotatedBindingBuilder[T] extends ScalaLinkedBindingBuilder[T] with AnnotatedBindingBuilderProxy[T] {
outer =>
def annotatedWith[...
Otherwise, this seems good to me; and thanks for the test! I hadn't realized we're inconsistently switching between javax imports and guice imports. |
Ahh I didn't see your other issue / pull request. That makes even more sense (w.r.t. javax vs not). |
…tatedConstantBindingBuilder to allow bindConstant().annotatedWithName(name).to(constant());
Should be ok now. I added annotatedWithName to ScalaAnnotatedConstantBindingBuilder to allow: bindConstant().annotatedWithName("name").to("constant") |
There's another |
Should be consistent now :). Unfortunately I dont' know how to thest this method. |
LGTM. I don't have merge permissions; so you'll have to wait for Thomas' approval. |
So, looking through this I noticed that ScalaAnnotatedConstantBindingBuilder has annotatedWithType and KeyExtensions has annotatedWith that appears to do the same thing. This wasn't changed in this pull request but am I crazy or should those be the same? On that same note, should annotatedWithName just be annotatedWith? I can't think of a reason the method call would ever be ambiguous even if we could annotate with something new in the future. Lastly, we need references to these in the README. I may or may not get around to building this on my own system this weekend. In the mean time, discuss the above. Also, Nate, you make reviewing things so much easier. ^_^ |
Any thoughts on what I mentioned. I never did get around to building this. I am also hoping Guice4 will finalize this century. |
I think what you're talking about is reasonable, but I don't think it can work. You can create the method 'annotatedWith[T: Manifest]' on ScalaAnnotatedConstantBindingBuilder, but you can't invoke it. I think the problem is that there are methods that exist on AnnotatedConstantBindingBuilder named 'annotatedWith' that accept a single parameter. So I think the compiler has a hard time realizing that you want to call the overloaded method. For example if I try to call (obviously this is a bad example to use Named, but it is an annotation which is useful for a quick test): binder.bindType[A].annotatedWith[Named].toType[B] Then I get this error:
But if the currently named method 'annotatedWithType' is called, then it compiles just fine. The reason that KeyExtensions gets away with this is because it's not actually enriching any guice objcet. So if anything then we should rename KeyExtensions. So then the question I haven't looked into is the can 'annotatedWithName' be called 'annotatedWith'... But, I would wonder if there are any types that have implicit conversions to String that would complicate the experience for what would otherwise be a compiler error. But it could be a completely unwarranted worry. |
Please look over https://github.com/codingwell/scala-guice/tree/release/4.0.0-beta4 and verify this appears to be merged correctly. I am going to move forward with these changes and address the previous concerns at a later date, this has been waiting long enough. |
Sure! I will take a look. |
It looks good for me. |
Added BindingProxies.annotatedWithName(name: String).
Example:
Added test for annotatedWithName UseCase.
Cleaned up imports.