This repository was archived by the owner on Feb 20, 2019. It is now read-only.
This repository was archived by the owner on Feb 20, 2019. It is now read-only.
Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag #158
Closed
Description
When testing pickling-0.8 with case class serialization, I got an error:
Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag[Person]
I managed to do some workaround to get rid of it, but I am not sure it's a wanted feature.
Here are two code snippets will help to reproduce the error:
Snippet 1:
object Test extends App {
import scala.pickling._
import json._
case class Person(name: String, age: Int) // case class defined out of func test()
def test() = {
val res = Person("Hao", 10).pickle.value
println(res)
}
test
}
This code is good and resulted in :
{
"tpe": "Test.Person",
"name": "Hao",
"age": 10
}
Snippet 2:
object Test extends App {
import scala.pickling._
import json._
def test() = {
case class Person(name: String, age: Int) // case class defined in func test
val res = Person("Hao", 10).pickle.value
println(res)
}
test
}
This code resulted in an error:
[error] /home/invoker/workspace/scalacode/sbt-example-pickling/Test.scala:7: could not find implicit value for parameter e: scala.pickling.FastTypeTag[Person]
[error] val res = Person("Hao", 10).pickle.value
[error] ^
[error] one error found
I can not understand why the position of case class definition matters. At compile time, the implicit parameter value is erased ? Does it do with the scala Macro feature ? Could someone show me any deep insights ? Highly appreciate that.
Hao