com-lihaoyi / upickle

uPickle: a simple, fast, dependency-free JSON & Binary (MessagePack) serialization library for Scala
https://com-lihaoyi.github.io/upickle
MIT License
707 stars 158 forks source link

macroRW: method annotate in trait Annotator is deprecated: Not used, left for binary compatibility #582

Closed avhou closed 1 month ago

avhou commented 1 month ago

Hi, after upgrading from 3.3.0 to 3.3.1 I'm getting compile issues when automatically deriving ReadWriters using macroRW. Error message is : method annotate in trait Annotator is deprecated: Not used, left for binary compatibility.

I'm using scala 2.13.14, sbt 1.10.0

I have a hierarchy like this :

  sealed trait AA
  object AA {
    implicit val rw: ReadWriter[AA] = macroRW
  }

  sealed trait BB extends AA
  object BB {
    implicit val rw: ReadWriter[BB] = macroRW
  }

  @upickle.implicits.key("key1")
  final case class CC(
      @upickle.implicits.key("key2") field: String
  ) extends BB
  object CC {
    implicit val rw: ReadWriter[CC] = macroRW
  }

This compiled in 3.3.0 but no longer does in 3.3.1. Am I missing something obvious here?

thanks!

lihaoyi commented 1 month ago

Seems related to https://github.com/com-lihaoyi/upickle/pull/579. @mrdziuban do you have any idea what's happening here?

mrdziuban commented 1 month ago

I'm taking a look but can't reproduce it with your code snippet @avhou. It compiles without deprecation both in Scastie and on my laptop. Are you using upickle.default? Would you be able to share a snippet that definitely has the deprecation warning?

mrdziuban commented 1 month ago

As far as I can tell, the only call to annotate in the Scala 2 macros is here which is referring to the new, non-deprecated version.

This is a shot in the dark, but is it possible that there's an incremental compilation issue involved here? That is, the macro invocation in your code wasn't recompiled so the code produced by macroRW is still the version from 3.3.0, but is referring to the annotate methods in 3.3.1.

Have you tried a clean followed by a compile?

avhou commented 1 month ago

@mrdziuban sorry, I forget to mention, I'm not using upickle.default, I'm using the Option to null instead of [] writer and reader (as documented). This was in another project and that project was still using upickle 3.2.0. After upgrading the project containing the customized reader and writer to 3.3.1, the problem disappeared.

Sorry I didn't think of this, thank you kindly for the quick replies!

mrdziuban commented 1 month ago

No worries! So you're all set and this is good to close?