question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Macro implicits don't work outside package

See original GitHub issue

Hey. Check this out: https://github.com/japgolly/upickle/commit/9a976af73ed46eeb7364829e457a973719ed9a7b

Eg2 compiles but Eg1 doesn’t.

[error] upickle/jvm/shared/test/scala/upickle/blah/blah.scala:7: uPickle does not know how to read [upickle.elsewhere.YYY]s; define an implicit Reader[upickle.elsewhere.YYY] to teach it how
[error]   def blah(j: String): YYY = read[YYY](j)
[error]                                       ^
[warn] one warning found
[error] one error found
[error] upickle/js/shared/test/scala/upickle/blah/blah.scala:7: uPickle does not know how to read [upickle.elsewhere.YYY]s; define an implicit Reader[upickle.elsewhere.YYY] to teach it how
[error]   def blah(j: String): YYY = read[YYY](j)
[error]                                       ^
[warn] one warning found
[error] one error found

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
l15k4commented, Feb 24, 2016

I knew that this issue made it so risky to choose upickle for a project and yet I did it again and here I am, chasing this issue for 3 hours… Even though my code is entirely within a single package and I know about a few other tricks that usually solved it like proper ordering and avoiding nested classes… And still god damn :

The referenced trait [[Aggregation]] does not have any sub-classes. This may happen due to a limitation of scalac (SI-7046) given that the trait is not in the same package. If this is the case, the hierarchy may be defined using integer constants.

The incremental compiler in Intellij is the biggest trap because it works works works until you do sbt clean and find it doesn’t work god knows why after 2 hours of development…

Anyway, rules of thumb :

  1. keep all components of model (trait, case classes) and serialization invocation within a single package
  2. don’t use nested classes
  3. keep AST ordering of components in your scala files, ie. if some case class inherits from a sealed trait, have this trait declared above the case class, etc. etc. etc.
  4. ???

Btw the @japgolly’s trick with “implicit realization close to data source” doesn’t work for me…

0reactions
lihaoyicommented, Dec 19, 2017

Moot with 0.5.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot resolve macro in implicit extern crates #3210 - GitHub
IntelliJ doesn't correctly resolve external crate macros when not explicitly marked in main/lib file and with a #[macro_use] . At a guess, I'm ......
Read more >
How do I use a macro across module files? - Stack Overflow
I want to use the macros defined in one module in another module. // macros.rs #[macro_export] // or not? is ineffectual for this,...
Read more >
Macros from the internet will be blocked by default in Office
Provides guidance for admins about how Office blocks macros in files from the internet.
Read more >
Macros - Scala 3
The two types can be defined in package scala.quoted as follows: ... assert that contains a splice operation outside an enclosing quote is...
Read more >
Def Macros - Scala Documentation
String . This also means that the code below won't work for printf(get_format(), ...) , because in that case format ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found