Git Product home page Git Product logo

Comments (15)

nbauernfeind avatar nbauernfeind commented on August 16, 2024

What versions of scala, guice, and scala-guice are you using?

from scala-guice.

shengc avatar shengc commented on August 16, 2024

scala 2.10.4, 4.0-beta5 for google guice, and 4.0.0-beta5 for scala-guice

from scala-guice.

nbauernfeind avatar nbauernfeind commented on August 16, 2024

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.

shengc avatar shengc commented on August 16, 2024

That made a lot of sense. Looking forward to it.

from scala-guice.

nbauernfeind avatar nbauernfeind commented on August 16, 2024

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.

vkostyukov avatar vkostyukov commented on August 16, 2024

Thanks a lot @nbauernfeind for working on TypeTag support. This is what I was looking for. Really looking forward to it.

from scala-guice.

nbauernfeind avatar nbauernfeind commented on August 16, 2024

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.

tsuckow avatar tsuckow commented on August 16, 2024

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.

tsuckow avatar tsuckow commented on August 16, 2024

Looks like 2.10 is curbing off. But still hundreds of users and 2.11 only has about half as many.

from scala-guice.

shengc avatar shengc commented on August 16, 2024

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.

nbauernfeind avatar nbauernfeind commented on August 16, 2024

@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.

nbauernfeind avatar nbauernfeind commented on August 16, 2024

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.

tsuckow avatar tsuckow commented on August 16, 2024

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.

halfninja avatar halfninja commented on August 16, 2024

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.

tsuckow avatar tsuckow commented on August 16, 2024

from scala-guice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.