We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
LowPriority and cachedImplicit seem to be incompatible:
LowPriority
cachedImplicit
package foo import shapeless.{ cachedImplicit, Generic, LowPriority } trait Foo[A] object Foo { implicit def fooForOption[A]: Foo[Option[A]] = new Foo[Option[A]] {} implicit def fooFromGeneric[A, R](implicit A: Generic.Aux[A, R], lowPrio: LowPriority): Foo[A] = new Foo[A] {} } object Bar { final case class MyClass(a: Int, b: Int) object MyClass { implicit val fooInstance: Foo[MyClass] = cachedImplicit[Foo[MyClass]] // ERROR } implicitly[Foo[Option[Int]]] }
The error is:
[error] .../Foo.scala:21: Could not find an implicit value of type foo.Foo[foo.Bar.MyClass] to cache [error] cachedImplicit[Foo[MyClass]] [error] ^
The following workaround (i.e., doing it without LowPriority) seem to work (but not always possible):
package foo import shapeless.{ cachedImplicit, Generic, LowPriority } trait Foo2[A] object Foo2 extends LowPrioFoo2 { implicit def fooForOption[A]: Foo2[Option[A]] = new Foo2[Option[A]] {} } trait LowPrioFoo2 { implicit def fooFromGeneric[A, R](implicit A: Generic.Aux[A, R]): Foo2[A] = new Foo2[A] {} } object Bar2 { final case class MyClass(a: Int, b: Int) object MyClass { implicit val fooInstance: Foo2[MyClass] = cachedImplicit[Foo2[MyClass]] } implicitly[Foo2[Option[Int]]] }
The text was updated successfully, but these errors were encountered:
I'm afraid that all of these mechanisms are a bit Heath Robinsonish ... I'm hoping to address the prioritization issue directly in the compiler.
Sorry, something went wrong.
No branches or pull requests
LowPriority
andcachedImplicit
seem to be incompatible:The error is:
The following workaround (i.e., doing it without
LowPriority
) seem to work (but not always possible):The text was updated successfully, but these errors were encountered: