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

Run after macro expansion #4

Closed
sellout opened this issue Jan 6, 2017 · 20 comments
Closed

Run after macro expansion #4

sellout opened this issue Jan 6, 2017 · 20 comments

Comments

@sellout
Copy link

sellout commented Jan 6, 2017

With Splain I’m getting an error saying that an implicit I reference doesn’t exist. My guess is that this is because the implicit in question is generated by Simulacrum’s @typeclass macro, and Splain is running before it generates the implicit.

@tek
Copy link
Owner

tek commented Jan 6, 2017

can you provide a test case? I'm not having any problems with simulacrum.

@sellout
Copy link
Author

sellout commented Jan 6, 2017

import simulacrum.typeclass

@typeclass trait Foo[A] {
  def foo(a: A): A
}

package object implicits extends Foo.ToFooOps

This errors with “not found: value Foo”. If I add a dummy companion object, it errors with “type ToFooOps is not a member of object Foo”. If I disable splain, it compiles cleanly. (My original code has a bunch of stuff in explicitly-created companion, so I didn’t see that first error before.)

@tek
Copy link
Owner

tek commented Jan 6, 2017

that's pretty peculiar…first of all, the error occurs even if the implicits feature is deactivated. also, the plugin doesn't really run at a specific time, it just overwrites some of the default phases. I don't have the slightest idea how this could be caused, but I'll try and dig around.

@tek
Copy link
Owner

tek commented Jan 8, 2017

so, I just noticed that your case failed when I tried because I was using a toolbox to compile the code, which, of course, doesn't include macro paradise just because it is an sbt dependency.
Testing in a regular environment resulted in successful compilation, so the problem must be more specific to your setup. Would you upload a minimal project that fails?

@sellout
Copy link
Author

sellout commented Jan 9, 2017

Oh, I have a theory … still narrowing it down, but this wouldn’t surprise me:

scalaOrganization := "org.typelevel"

@sellout
Copy link
Author

sellout commented Jan 9, 2017

Nope.

@sellout
Copy link
Author

sellout commented Jan 9, 2017

Ok, I have a very minimal project at https://github.com/sellout/matryoshka/tree/test-splain that still fails. It’s being built with sbt 0.13.13 and ~/.sbt has been removed.

Commenting out the Splain plugin makes it compile (with a feature warning that can be eliminated by adding scalacOptions += "-language:implicitConversions").

@tek
Copy link
Owner

tek commented Jan 9, 2017

this is really weird, but it works for me if I change the paradise version spec to 2.1.+.
Even though that doesn't change the actual version.

@sellout
Copy link
Author

sellout commented Jan 9, 2017

Hrmm, I still have no luck with

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.+" cross CrossVersion.full)

@tek
Copy link
Owner

tek commented Jan 9, 2017

the only thing that comes to mind is that the change triggered some reordering of the plugins, but it seems to work pretty consistently here. very strange

@jrgonzalezg
Copy link

A similar issue also happened to me using https://github.com/frees-io/freestyle that depends on https://github.com/scalamacros/paradise . After reading the comments about reordering here i got my project working by adding the splain compiler plugin before the paradise one so that may also help on similar cases.

@tek
Copy link
Owner

tek commented May 8, 2017

huh, interesting!

@jrgonzalezg
Copy link

But today i added coursier (https://github.com/coursier/coursier) and build fails again and the reordering does not help in this case, so the workaround seems to be very fragile...

@nafg
Copy link

nafg commented Nov 15, 2018

Somehow 0.3.4 is breaking monocle @Lenses, while 0.3.3 is fine. At least on this project. I'm pretty sure it didn't cause issues elsewhere.

Is splain modifying any trees?

@tek
Copy link
Owner

tek commented Nov 15, 2018

I wish I could give you an answer 😄 it seems to be completely random

@julianmichael
Copy link

I've had this issue a couple times now, with implicits from simulacrum (@typeclass), circe-generic (@JsonCodec), and monocle (@Lenses) all missing when I include splain in the build process. Weirdly it seems to depend on something the build tool is doing, because the same exact build works fine on mill 0.2.3 but not 0.3.5. I don't have the bandwidth to dig into it in more detail (nor do I expect anything), but just thought I would drop in the extra data point for anyone else finding this.

@nafg
Copy link

nafg commented Feb 17, 2019

Is splain modifying trees?

btw 0.4.0 seems much worse, it breaks monocle much more

@tek
Copy link
Owner

tek commented Feb 18, 2019

nope, no modifications.

@tek
Copy link
Owner

tek commented Feb 22, 2019

hello dear reporters, please take a look at the new PR for integration into scalac: scala/scala#7785

@tek
Copy link
Owner

tek commented May 22, 2021

fixed by scala/scala#7785

@tek tek closed this as completed May 22, 2021
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

5 participants