EindbaasExpress / handsonscala-issuemigrator

Part of the HandsOnScala Course
0 stars 0 forks source link

Issue with sealed traits #28

Open EindbaasExpress opened 2 years ago

EindbaasExpress commented 2 years ago

I think this particular bug has to do with a a sealed trait with only a single case class or case object (See random notes).

In MacroTests.scala, adding the following lines:

object DeepHierarchy {
  sealed trait A
  case class B(i: Int) extends A
  sealed trait C extends A
  case class D(s: String) extends C
  case class E(b: Boolean) extends C
  sealed trait Q //new line
  case object AnQ extends Q //new line 
  case class F(q: Q) extends C //new line
}

and running test:compile causes:

[error] one error found [error] /home/nick/projects/upickle/js/../shared/test/scala/upickle/MacroTests.scala:138: could not find implicit value for evidence parameter of type upickle.Writer[upickle.DeepHierarchy.A] [error] rw(B(1): A, """["upickle.DeepHierarchy.B", {"i": 1}]""

...but then adding

case object AnOtherQ extends Q

leads to success ???

Random notes:

Adding a third other other Q is still a success...

going back to just one AnQ recreates the error...

Using:

case object AnQ 
case class F(q: AnQ.type) extends C

Throws the same compile error (removed sealed trait Q).

However,

case class AnQ(i: Int)
case class F(q: AnQ) extends C

Is a success...

But

  sealed trait Q
  case class AnQ(i: Int) extends Q
  case class F(q: Q) extends C

errors...

Which is again fixed if the seconds case object is added (AnOtherQ extends Q )is added...

ID: 9 Original Author: Voltir