argonaut-io/argonaut

seriously weird issue in 6.2-M1

tpolecat opened this issue · 3 comments

Ok you need to be with me here. This is kind of nuts.

object Uh {

  import argonaut.DecodeJson

  // A trivial typeclass
  trait Whatever[A]

  // An instance
  trait Foo
  object Foo {
    implicit val wf: Whatever[Foo] = null
  }

  // Whatever[A] implies DecodeJson[A] 
  implicit def wd[A: Whatever]: DecodeJson[A] = null

  // ... or does it?
  implicitly[DecodeJson[Foo]]

}

Computer says no.

[error] /Users/rnorris/Scala/gem/modules/json/src/main/scala/gem/uhh.scala:18: could not find implicit value for parameter e: argonaut.DecodeJson[Uh.Foo]
[error]   implicitly[DecodeJson[Foo]]

However this works fine if you s/Decode/Encode/ or if you move the definition wf out of the companion object or if you use Argonaut 6.1.

I'm going to check see if anything shows up in the diff but wanted to write this down for reference. Any hints would be appreciated. Seems like this will hit many users.

Verified in isolation.

Ok well it works in 6.1-M3 which doesn't appear in the doc but I assume it's a legit milestone release. I'll let you close this.

It was a consequence of covariance, which briefly appeared for M1. Good enough.

I had a suspicion that it is because @tpolecat ❤ variance