Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests do not compile with Scala 2.11 #78

Closed
propensive opened this issue Feb 26, 2018 · 10 comments
Closed

Tests do not compile with Scala 2.11 #78

propensive opened this issue Feb 26, 2018 · 10 comments

Comments

@propensive
Copy link
Collaborator

Looks like @joroKr21's stack reworking introduced something, which appears to affect only Scala 2.11, and currently stops four tests from compiling... I've seen error messages suggestion something relating to lazy vals.

@joroKr21
Copy link
Contributor

I don't know about lazy vals, but one thing I noticed for sure in #73 is that DirectlyReentrantException always triggers on recursive types, but then we recover. That happens because we first try the regular implicit resolution and we always find our own macro and then we fall back to direct recursive derivation. That may or may not have happened before but apart from causing #73 it must be horribly inefficient so there is even room for speedup! I'm not sure how to fix it yet though.

@propensive
Copy link
Collaborator Author

The DirectlyReentrantException hack was very much part of the original design, and it effectively uses implicit search to check whether there is a non-Magolia implicit in scope for that particular search which should take precedence. I don't know of a better way to do this... It's only an exception in that we want a nested macro invocation to fail so that we can search for other suitable implicits that would otherwise be shadowed...

I'm just investigating some more, though... :)

@propensive
Copy link
Collaborator Author

Here are the errors, by the way;

[info] Compiling 1 Scala source to /home/jpretty/dev/propensive.com/magnolia/tests/target/scala-2.11/classes ...
[error] /home/jpretty/dev/propensive.com/magnolia/tests/src/main/scala/tests.scala:130:17: could not find implicit value for parameter e: magnolia.examples.Show[String,magnolia.tests.FruitBasket]
[error]       implicitly[Show[String, FruitBasket]].show(FruitBasket(Fruit("apple"), Fruit("banana")))
[error]                 ^
[error] /home/jpretty/dev/propensive.com/magnolia/tests/src/main/scala/tests.scala:237:15: not found: value companyTypeclass$macro$255$lzy
[error]       Show.gen[Politician[String]].show(Corrupt("wall", Seq(Company("Alice Inc"))))
[error]               ^
[error] /home/jpretty/dev/propensive.com/magnolia/tests/src/main/scala/tests.scala:333:15: not found: value companyTypeclass$macro$352$lzy
[error]       Show.gen[Portfolio].show(Portfolio(Company("Alice Inc"), Company("Bob & Co")))
[error]               ^
[error] /home/jpretty/dev/propensive.com/magnolia/tests/src/main/scala/tests.scala:381:15: not found: value pathTypeclass$macro$425$lzy
[error]       Show.gen[Path[String]].show(OffRoad(Some(Crossroad(Destination("A"), Destination("B")))))
[error]               ^
[error] four errors found

@joroKr21
Copy link
Contributor

I completely forgot about scala/bug#5466 (note the $lzy suffix)

@joroKr21
Copy link
Contributor

Also, it seems that currently crossScalaVersions in tests is only 2.12

@propensive
Copy link
Collaborator Author

Ah, does that mean we can get it working again on Scala 2.11 with some targetted untypechecking?

@joroKr21
Copy link
Contributor

Rather the opposite - the problems is that we use c.untypecheck on code that contains lazy vals.

@propensive
Copy link
Collaborator Author

Oh, I see. I can see some logic (I think) for the cases where it's happening...

I imagine that in an absolute worst-case scenario we could replace them with some dummy code, and rewrite that code as actual lazy vals when the macro finally produces output. But maybe you know a more straightforward workaround?

@joroKr21
Copy link
Contributor

I don't know of any straightforward workaround. I'm not even sure what you're suggesting will work but you're welcome to try. In general the splicing of typed and untyped trees is an unsolved problem in scala.reflect. You can try to avoid calling untypecheck (it's only one place). Maybe typingTransform can be used? No easy solution I'm afraid.

@adamw
Copy link
Member

adamw commented Jul 10, 2019

Fixed by removing 2.11 support :)

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

No branches or pull requests

3 participants