scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

value unpickle is not a member of String #198

Closed alexkvak closed 10 years ago

alexkvak commented 10 years ago

Before the latest updates I had work code, and now I have the error

Error:(113, 23) value unpickle is not a member of String
 apiState = pickle.unpickle[ApiState]
                   ^

Library version is 0.9.0-SNAPSHOT

Please fix it ASAP

Strate commented 10 years ago

+1

heathermiller commented 10 years ago

We'd like to help, but this isn't enough information for us to be able to debug the issue. Could you provide us with a self-contained example? For example, we need to know what pickle is as well as ApiState.

Thanks!

heathermiller commented 10 years ago

By the way, we're just about ready to cut a 0.9.0 release, so if you can help us debug your issue, we can hopefully make sure that the fix gets into 0.9.0.

heathermiller commented 10 years ago

Also worth noting – unpickle is now an extension method, just like pickle, and thus it should be imported, typically via import scala.pickling._. Make sure your imports are correct. If they are, could you please provide a complete example that fails?

alexkvak commented 10 years ago
case class ApiState(primaryDc: Int,
    keys: Map[Int, Array[Byte]],
    isAuth: Map[Int, Boolean],
    connections: Map[Int, Iterable[ConnectionInfoState]],
    mtProtos: Map[Int, MTProtoState]
)
case class ConnectionInfoState(id: Int, priority: Int, address: String, port: Int)
class MTProtoState(val dcId: Int, private[this] var apiStorage: TelegramApiState) extends AbsMTProtoState {

  // cannot be private[this] because of picking
  private var knownSalts: Array[KnownSaltInfo] = new Array[KnownSaltInfo](0)
 // ...
}

https://github.com/ex3ndr/telegram-api/blob/ac6e15aa142ffe76d97961c02ee5f0b4a56a8ff2/src/main/java/org/telegram/api/engine/storage/AbsApiState.java

case class KnownSaltInfo(validSince: Int, validUntil: Int, salt: Long)
alexkvak commented 10 years ago

If I use 0.8.0 everything works fine. I suspect this pull request https://github.com/scala/pickling/pull/196

heathermiller commented 10 years ago

I still need more info. Is there any way you can provide a complete example?

heathermiller commented 10 years ago

I need to know what the type of pickle is, what pickle format you're using, etc. Ideally something self-contained enough to copy/paste into a REPL would help.

alexkvak commented 10 years ago

I use only standard pickle formats, no custom format is used

alexkvak commented 10 years ago
def unserialize(pickle: String): Unit = {
    apiState = pickle.unpickle[ApiState]
    // restore references to current ApiStorage
    apiState.mtProtos.map(_._2.setApiStorage(this))
  }

this is my unserialize function

heathermiller commented 10 years ago

I think I've got a fix for you, after merge (conditional on it passing the test suite), perhaps you could verify that this works for you? Either by checking out pickling and trying your use case in the REPL, locally building, or waiting until tomorrow's 0.9.0-SNAPSHOT to try again.

alexkvak commented 10 years ago

ok, I'll try tomorrow with fresh snapshot build. Thanks for quick problem resolution

alexkvak commented 10 years ago

everything works like a charm, thanks!

heathermiller commented 10 years ago

Great! Happy to hear!