-
Notifications
You must be signed in to change notification settings - Fork 542
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
Upgrade to cats 1.0.0-MF #724
Conversation
I was just about to post almost identical PR :) In this test case: circe/modules/generic/shared/src/test/scala/io/circe/generic/AutoDerivedSuite.scala Lines 127 to 134 in e9d99ba
Decoding ends up here:
My guess is that Interestingly, only auto derived decoder is affected with this problem. semi-auto derivation of incomplete decoder is OK: circe/modules/generic/shared/src/test/scala/io/circe/generic/SemiautoDerivedSuite.scala Lines 27 to 28 in e9d99ba
Anyway, adding |
I completely forgot what Travis had said to me on twitter:
I'll try and get rid of the plugin entirely. On a complete tangent, @rkrzewski what's the markup for these fancy code block references? |
I agree, but it may show up as a problem on the Circe user's side: when they'll use Cats 1.+, they'll probably use Regarding the code blocks, just paste URL or a source file on github and use a line range eg. |
I was trying to dig into the failure in
implicit val decoder = io.circe.generic.semiauto.deriveFor[Int => Qux[String]].incomplete
implicit val decoder = implicitly[io.circe.export.Exported[Decoder[Int => Qux[String]]]].instance
implicit val decoder = implicitly[Decoder[Int => Qux[String]]] 2 and 3 should basically be the same thing, right? Maybe it's a scalac bug? The upside is that even with |
Thanks for the investigation, @dwijnand, @rkrzewski. I don't have a sense of why the compiler might think that My feeling is that we could release 0.9.0-M1 with this as a known issue (i.e. "if you use |
Yeah, there must be a rouge
👍 |
Codecov Report
@@ Coverage Diff @@
## master #724 +/- ##
==========================================
- Coverage 86.72% 86.63% -0.09%
==========================================
Files 71 71
Lines 2267 2267
Branches 91 88 -3
==========================================
- Hits 1966 1964 -2
- Misses 301 303 +2
Continue to review full report at Codecov.
|
@travisbrown I went with your suggestion. However I didn't know where to document the known issue, so for now I've put it next to the reference to incomplete decoders in the docs. |
…tion I did further investigation of test failures related to `-Ypartial-unification` discovered in circe#724. Here are my findings: 1) Summoning the partial `Decoder` directly yields nonsensical result while summoning an `Exported[Decoder[...]]` yields correct result because `importedDecoder` is located in `LowerPriorityDecoder`, so `decodeCanBuildFrom` implicit has higher priority. 2) `decodeCanBuildFrom` is tried because under `-Ypartial-unification` `Int => Qux[String]` is partially unapplied as `[T]Int => T` to fit into `C[_]` shape of second parameter to `def decodeCanBuildFrom[A, C[_]]`. 3) `decodeCanBuildFrom` succeeds because an instance of `CanBuildFrom[Nothing, Qux[String], Int => Qux[String]]` exists. The instance, as it usually happens, is helpfully provided by `scala.Predef`: `implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]]`. `CanBuildFrom` has variance of `[-,-,+]` so the types align nicely. This means that the problem is limited to partial decoders with `Int` typed hole, but it's also means it's easy to remedy by adding a constraint on `decodeCanBuildFrom` parameter to ensure it actually a collection, not an `Int => _`. I've used `Traversable`, which in turn required adding separate case for `Array` that is not a `Traversable` but needs a `CanBuildFrom` to handle. This patch does not turn on `-Ypartial-unification`, but I've verified that all the tests pass with and without this option on Scala 2.11 and 2.12
…ation I did further investigation of test failures related to `-Ypartial-unification` discovered in circe#724. Here are my findings: 1) Summoning the partial `Decoder` directly yields nonsensical result while summoning an `Exported[Decoder[...]]` yields correct result because `importedDecoder` is located in `LowerPriorityDecoder`, so `decodeCanBuildFrom` implicit has higher priority. 2) `decodeCanBuildFrom` is tried because under `-Ypartial-unification` `Int => Qux[String]` is partially unapplied as `[T]Int => T` to fit into `C[_]` shape of second parameter to `def decodeCanBuildFrom[A, C[_]]`. 3) `decodeCanBuildFrom` succeeds because an instance of `CanBuildFrom[Nothing, Qux[String], Int => Qux[String]]` exists. The instance, as it usually happens, is helpfully provided by `scala.Predef`: `implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]]`. `CanBuildFrom` has variance of `[-,-,+]` so the types align nicely. This means that the problem is limited to partial decoders with `Int` typed hole, but it's also means it's easy to remedy by adding a constraint on `decodeCanBuildFrom` parameter to ensure it actually a collection, not an `Int => _`. I've used `Traversable`, which in turn required adding separate case for `Array` that is not a `Traversable` but needs a `CanBuildFrom` to handle. This patch does not turn on `-Ypartial-unification`, but I've verified that all the tests pass with and without this option on Scala 2.11 and 2.12
No description provided.