Comments (15)
What versions of scala, guice, and scala-guice are you using?
from scala-guice.
scala 2.10.4, 4.0-beta5 for google guice, and 4.0.0-beta5 for scala-guice
from scala-guice.
The underlying issue is that scalaz.Reader
is typedef'd to scalaz.Kleisli
which has a type parameter that takes a type parameter.
Here's a shorter example that does not use scalaz or guice:
class A[T[_]]
manifest[A[List]] // No Manifest available
This leads me to this stackoverflow on the issue: http://stackoverflow.com/questions/26010800/why-does-getting-a-manifest-of-a-trait-with-a-higher-kinded-type-does-not-work
It seems like we won't be able to support this until we move to TypeTags. I'm going to try to squeeze it in as soon as I can.
from scala-guice.
That made a lot of sense. Looking forward to it.
from scala-guice.
I've banged out the required changes to migrate from Manifest to TypeTag and they can be previewed here:
https://github.com/nbauernfeind/scala-guice/tree/TypeTag
There is a pretty big drawback to TypeTags, and that's that they are not thread safe in Scala 2.10.
See: https://issues.scala-lang.org/browse/SI-6240
I've, personally, coded around this for scala-guice library. However, it is basically impossible to coordinate across other libraries that might also be using TypeTags. That might be a big negative to other users of scala 2.10.
I still need to add a specific test case for your use, but I believe that this works for your use case.
@tsuckow, I could use your input here. Should we push forward with this change and begin to "deprecate" Scala 2.10?
from scala-guice.
Thanks a lot @nbauernfeind for working on TypeTag
support. This is what I was looking for. Really looking forward to it.
from scala-guice.
You're welcome @vkostyukov.
I wrote those tests (haven't pushed them to my branch yet) and found a couple of edge-cases that are wrong related to Arrays. Arrays are tricky since there isn't a real class that supports them. JVM has a flag on the class instance to say whether or not the type is an array. With this particular use case the type tag doesn't conform to typeOf[Array[_]]
so I'm trying to find another way to fix that.
from scala-guice.
I'll pull the sonatype stats and see what usage looks like. I would hate to maintain a separate branch, but that may be the best if we have to hack 2.10 or leave it broken.
from scala-guice.
Looks like 2.10 is curbing off. But still hundreds of users and 2.11 only has about half as many.
from scala-guice.
Guys found another case that is similar to this....
trait A { def a {} }
trait B
type AB = A with B
class Model extends AbstractModule with ScalaModule {
def configure() {
bind[A].toInstance(new A {})
bind[AB].toInstance(new A with B {})
}
}
Guice.createInjector(new Model()) // This fails at run time. Guice thinks binds are dups.
from scala-guice.
@tsuckow I think that's probably fine. If someone has to care or runs into that problem we just direct them to the earlier versions of 2.10. Most of the time people don't upgrade to 2.11 because of other third party dependencies. Twitter is usually one of the last companies to upgrade and I see most of their popular projects have already upgraded. Let's just deprecate 2.10 and move on.
@shengc I've filed a separate issue for your second example since I'd prefer to deal with them separately. I haven't had a chance to find out why or if TypeTags fix them, yet. #43
from scala-guice.
Also, it appears I didn't finish my changes related to Arrays. I'll add that to my todo list this weekend and send a proper pull-request.
from scala-guice.
So 4.2.1 has a conversion of typeLiteral[T] to use TypeTag. I started looking at replacing occurrences of Manifest with TypeTag. I'll see about adding this as a test case and see what happens.
I should also look into the compilation assertions, I would like to add some expected failures on some of the tickets with corner cases like this. But maybe with Typetags they will all be fixed. ¯_(ツ)_/¯
from scala-guice.
Now that 2.10 support is gone, it's worth noting that Dotty (soon to become Scala 3) will no longer synthesize Manifest instances, so there are two reasons to move to type tags. Is there still a branch around somewhere?
from scala-guice.
from scala-guice.
Related Issues (20)
- Issue using ScalaMapBinder with Scala Int as a key or a value
- Is there any scala-guice implementation for Custom Injections? HOT 1
- git tag missing for version 5.1.0 HOT 1
- No TypeLiteral for types taking a slick.dbio.DBIO as type parameter can be created
- Binding wildcard types doesn't use correct type literal HOT 1
- getInstance() with constructor parametrs HOT 1
- Can't attach Singleton scope toProvider HOT 1
- Add compatibility with Scala 2.13 HOT 4
- Problems with Play framework's dev mode after upgrading to scala-guice 4.2.2 HOT 3
- Replace uses of Manifest with ClassTag / TypeTag HOT 4
- SingletonType bindings not working since 4.2.2 HOT 11
- injector.instance[Foo[Array[Byte]] does not properly find the bound type HOT 5
- injector.instance[Class with Trait] throws UnsupportedException HOT 5
- Add provider to InjectorExtensions HOT 1
- TypeConversions produces an incorrect TypeLiteral for Scala value classes HOT 11
- ScalaModule#bind[static nested class of an inner class] cannot find inner class HOT 3
- New guice has been released HOT 2
- bind[X[Nothing]] fails when trying to instatiate Nothing. HOT 4
- Scala 3? HOT 6
- injectMembers silently fails to inject members on Scala 2.13.6 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-guice.