amnaredo / test

0 stars 0 forks source link

Compilation time takes long to discover missing implicit for unknown type #144

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago

When I have missing import for Date type pickler, I can get error

Error:(41, 27) Couldn't derive type Seq[A$A133.this.MainStruct]
    read[Seq[MainStruct]](jsonString)
                         ^

It is nice, but when I have nontrivial code, it takes long to get this error (really long). Try this example and after compilation error try to uncomment line with timeKiller and try it again. Than try uncomment timeKiller2 and try again. And so on. It takes about minute to see compilation error on my PC with timeKiller uncommented. With all time killers active, my compilation did not finished after 40 minutes. It was a lot frustrating to find out that actual problem was in missing implicit.

import java.util.Date
import upickle.default._
import upickle.Js

private case class SubStruct(val from: Date) {
  def asAnotherType() = {
    (from, None)
  }
}

private case class MainStruct(id: Option[Int],
                               //timeKiller: Option[Double],
                               //timeKiller2: Option[Double],
                               //timeKiller3: Option[Double],
                               //timeKiller4: Option[Double],
                               //timeKiller5: Option[Double],
                               //timeKiller6: Option[Double],
                               consumption: Seq[SubStruct]
                             ) {
  def asAnotherStruct() = {
    (id, consumption.map(c => c.asAnotherType()))
  }
}

private def convertData(jsonString: String) = {
  val componentsRaw =
    read[Seq[MainStruct]](jsonString)
  val components = componentsRaw.map(x => x.asAnotherStruct())
  components
}

ID: 110 Original Author: LubomirVarga

amnaredo commented 3 years ago

Bug bankruptcy Original Author: lihaoyi