Skip to content
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
invkrh opened this issue Aug 11, 2014 · 2 comments
Labels

Comments

@invkrh
Copy link

invkrh commented Aug 11, 2014

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

@invkrh invkrh changed the title Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag, source code and workaround attached Aug 11, 2014
@invkrh invkrh changed the title Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag, source code and workaround attached Error: could not find implicit value for parameter e: scala.pickling.FastTypeTag Aug 11, 2014
heathermiller added a commit that referenced this issue Aug 20, 2014
@invkrh
Copy link
Author

invkrh commented Sep 26, 2014

Is this fixed ? Any insight here ?

heathermiller added a commit that referenced this issue Feb 5, 2015
@eed3si9n
Copy link
Member

eed3si9n commented Feb 8, 2015

After changing to import scala.pickling._, Defaults._ both cases works for me using Pickling 0.10.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants