Skip to content
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

Implicit resolution error in REPR #8

Open
limansky opened this issue Jan 16, 2017 · 3 comments
Open

Implicit resolution error in REPR #8

limansky opened this issue Jan 16, 2017 · 3 comments

Comments

@limansky
Copy link

I've found that I got compilation error in REPR when the splain plugin is enabled:

scala> import shapeless._, me.limansky._, cats.instances.all._
import shapeless._
import me.limansky._
import cats.instances.all._

scala> case class Foo(n: Int); case class Bar(s: String, f: Foo)
defined class Foo
defined class Bar

scala> MapReader[Bar].read(Map("s" -> "b", "n" -> "6"))
<console>:25: error: implicit error;
!I ev: MapReader[Bar]
MapReader.genericReader invalid because
!I mapReader: MapReader[R]
Generic.materialize invalid because
type parameters weren't correctly instantiated outside of the implicit tree: inferred type arguments [shapeless.::[String,shapeless.::[Foo,shapeless.HNil]],Nothing] do not conform to method materializeCoproduct's type parameter bounds [V <: shapeless.Coproduct,R <: shapeless.Coproduct]
       MapReader[Bar].read(Map("s" -> "b", "n" -> "6"))

The same code without plugin works fine:

scala> import shapeless._, me.limansky._
import shapeless._
import me.limansky._

scala> import shapeless._, me.limansky._, cats.instances.all._
import shapeless._
import me.limansky._
import cats.instances.all._

scala> case class Foo(n: Int); case class Bar(s: String, f: Foo)
defined class Foo
defined class Bar

scala> MapReader[Bar].read(Map("s" -> "b", "n" -> "6"))
res0: Bar = Bar(b,Foo(6))

The code is available in this gist: https://gist.github.com/limansky/7c91a3deaa25fc0ec7339ea191d4a54a

It looks like the problem is reproducible only in REPR, at least the tests are compiled and passed successfully.

@tek
Copy link
Owner

tek commented Jan 17, 2017

does it happen as well if you deactivate the plugin features via -P:splain:all:false?

@limansky
Copy link
Author

limansky commented Jan 17, 2017

Yes it does. In this case it doesn't explain the error:

scala> MapReader[Bar].read(Map("s" -> "b", "n" -> "6"))
<console>:25: error: could not find implicit value for parameter ev: me.limansky.MapReader[Bar]
       MapReader[Bar].read(Map("s" -> "b", "n" -> "6"))

@tek
Copy link
Owner

tek commented Jan 17, 2017

then it's probably analogous to #4, due to the nature of the reflective hack used to hijack the compiler phases. it's likeley this isn't going to be fixed until I implement parts of the plugin in the compiler itself, which is hopefully soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants