-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Diverging implicit with 1-class-recursive-discriminated-union #30
Comments
This happens in both 2.10.4 and 2.11.2 |
sealed trait Inline
case class Emph(content: Seq[Inline]) extends Inline
sealed trait Block
case class Plain(content: Seq[Inline]) extends Block
upickle.read[Block]("") I used SeqishR is not a valid implicit value for upickle.Reader[Block] because:
hasMatchingSymbol reported error: polymorphic expression cannot be instantiated to expected type;
found : [T, V[_]]upickle.Aliases.R[V[T]]
(which expands to) [T, V[_]]upickle.Reader[V[T]]
required: upickle.Reader[Block]
println(read[Block](""))
^
diverging implicit expansion for type upickle.Reader[Seq[Inline]]
starting with method SeqishR in trait Implicits
println(read[Block](""))
^ It is probably related to this bug. Note that replacing I am confused by the type the expression requires. Shouldn't it be |
Reported by @MasseGuillaume case class Bucket(name: String, objects: Seq[S3Node])
sealed trait S3Node
case class S3Folder(path: String, nodes: Seq[S3Node]) extends S3Node
case class S3File(path: String) extends S3Node
import upickle._
write(Bucket("a", Seq(S3Folder("b", Seq(S3File("c"))))))
java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:151)
at upickle.Macros$.macroWImpl(Macros.scala:49)
write(Bucket("a", Seq(S3Folder("b", Seq(S3File("c")))))) |
default parameters are also not working sealed trait Node
case class Branch(value: String, nodes: Seq[Node] = Seq()) extends Node
case class Leaf(value: String) extends Node |
The original case is fixed in |
Here's a minimal repro of AFAIK what everyone is facing. These fails: // Doesn't work :(
case class A_(objects: Option[C_]); case class C_(nodes: Option[C_])
case class A_(objects: Seq[C_]); case class C_(nodes: Seq[C_])
case class A_(objects: List[C_]); case class C_(nodes: List[C_])
implicitly[Reader[A_]] While these work case class A_(objects: Option[C_]); case class C_(nodes: Seq[C_])
case class A_(objects: List[C_]); case class C_(nodes: Seq[C_])
case class A_(objects: List[C_]); case class C_(nodes: Option[C_])
implicitly[Reader[A_]] I haven't figured out why, but my $$$ is a bug in scalac's diverging implicit expansion checker which kicks in and kills the implicit search when it tries to cross two different implicits with the same type. This is normally a problem but should be OK in this case because the types in scope for the two implicits are different, so they should give different results. If anyone wants to help dive into this I'd be grateful |
Here's a more minimum repro case class C(nodes: Option[C])
object Main{
implicitly[upickle.default.Writer[Option[C]]]
} |
Another example:
|
Moot with 0.5.1 |
This causes uPickle to fail with a diverging implicit expansion error:
It really shouldn't, but I haven't managed to figure out why. Oddly enough, adding a
: SingleTree
type annotation or removing thechildren: List[SingleTree]
fromSingleNode
is sufficient to make the problem go away.The text was updated successfully, but these errors were encountered: