imp icon indicating copy to clipboard operation
imp copied to clipboard

Support both JS/JVM and 2.10/2.11 via unmanagedSourceDirectories

Open non opened this issue 9 years ago • 6 comments

While adding scala.js support, I was forced to remove the src/main/scala_2.10 and src/main/scala_2.11 directories. Previously we used:

unmanagedSourceDirectories in Compile +=
  (sourceDirectory in Compile).value / s"scala_${scalaBinaryVersion.value}"

This didn't work with scala.js, so I was forced to write macros that worked in both 2.10 and 2.11. However, this makes the macros under 2.11 slightly less powerful.

Old code (more powerful):

def summon[Ev](c: Context)(ev: c.Tree): c.Tree = ev

New code (2.10 compatible):

def summon[Ev](c: Context)(ev: c.Expr[Ev]): c.Expr[Ev] = ev

non avatar Jul 17 '15 03:07 non

Why or in what way is the new version less powerful? I'm fairly new to macros and looking at the two signatures, I don't understand the difference.

japgolly avatar Jul 17 '15 10:07 japgolly

Also, if you haven't read the following link, I think it would be helpful wrt this issue:

http://www.scala-js.org/api/sbt-scalajs/0.6.4/#org.scalajs.sbtplugin.cross.CrossProject

japgolly avatar Jul 17 '15 10:07 japgolly

@japgolly My understanding is that with the current macro if you "summon" an X you get something back of exactly that type. With the older code, the return type could possibly be refined to something more specific.

This additional specificity isn't something that I need in most cases but my understanding is that libraries like Shapeless do really benefit from it.

non avatar Jul 17 '15 10:07 non

Trying to cross build 2.10 and 2.11 here may also run aground on https://github.com/InTheNow/sbt-scalajs/issues/19 now that we are publishing for scala.js too.

non avatar Jul 20 '15 13:07 non

Also, discipline is not released, despite https://github.com/typelevel/discipline/pull/13

ghost avatar Jul 20 '15 19:07 ghost

Now that macro-compat is out, would you be looking to support the 2.11 more powerful and 2.10 less powerful at the same time? I'm asking because I'm very interested in seeing what this project could do for things we're working on at work.

wheaties avatar Dec 08 '15 21:12 wheaties