Can not produce a working scala macros type provider setup in eclipse.
1) discussions:
https://groups.google.com/forum/#!topic/scala-user/eiK1o1hmiL0
https://groups.google.com/forum/#!topic/scalameta/Q_3GO7hB6Yg
https://groups.google.com/forum/#!topic/scala-ide-user/sqOhZemjzrA
2) sample project:
https://github.com/carrot-garden/carrot-scala-macro-tester
3) problem:
scala macro with annotated type provider, such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala
crashes scala ide presentation compiler with errors such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala
" top-level class without companion can only expand either into an eponymous class or into a block consisting in eponymous companions"
if you keep doing "Eclipse -> Scala -> Restart Presentation Compiler", scala ide might start working, but crashes again after any major edit attempt
scala ide logs show no compiler crash errors, but error markers are created in eclipse error console, and these errors disappear with "restart presentation compiler"
4) environment
uname -a
Linux wks002 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 1a (4.4.1)
Build id: 20150109-0600
Scala IDE for Eclipse 4.0.0.v-2_11-201501121809-027320c org.scala-ide.sdt.feature.feature.group scala-ide.org
Tried the following combinations:
scala 2.11.4 with "org.scalamacros" % "paradise_2.11.4" % "2.0.1"
scala 2.11.5 with "org.scalamacros" % "paradise_2.11.5" % "2.0.1"
scala 2.11.4 with "org.scalamacros" % "paradise_2.11.4" % "2.1.0-M3"
scala 2.11.5 with "org.scalamacros" % "paradise_2.11.5" % "2.1.0-M3"
1) discussions:
https://groups.google.com/forum/#!topic/scala-user/eiK1o1hmiL0
https://groups.google.com/forum/#!topic/scalameta/Q_3GO7hB6Yg
https://groups.google.com/forum/#!topic/scala-ide-user/sqOhZemjzrA
2) sample project:
https://github.com/carrot-garden/carrot-scala-macro-tester
3) problem:
scala macro with annotated type provider, such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala
crashes scala ide presentation compiler with errors such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala
" top-level class without companion can only expand either into an eponymous class or into a block consisting in eponymous companions"
if you keep doing "Eclipse -> Scala -> Restart Presentation Compiler", scala ide might start working, but crashes again after any major edit attempt
scala ide logs show no compiler crash errors, but error markers are created in eclipse error console, and these errors disappear with "restart presentation compiler"
4) environment
uname -a
Linux wks002 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Eclipse Java EE IDE for Web Developers.
Version: Luna Service Release 1a (4.4.1)
Build id: 20150109-0600
Scala IDE for Eclipse 4.0.0.v-2_11-201501121809-027320c org.scala-ide.sdt.feature.feature.group scala-ide.org
Tried the following combinations:
scala 2.11.4 with "org.scalamacros" % "paradise_2.11.4" % "2.0.1"
scala 2.11.5 with "org.scalamacros" % "paradise_2.11.5" % "2.0.1"
scala 2.11.4 with "org.scalamacros" % "paradise_2.11.4" % "2.1.0-M3"
scala 2.11.5 with "org.scalamacros" % "paradise_2.11.5" % "2.1.0-M3"
Leave a comment
on 2015-01-17 14:23 *
By Andrei Pozolotin
on 2015-01-17 14:48 *
By Andrei Pozolotin
Asked Eugene Burmako for help:
https://github.com/scalamacros/paradise/issues/61
https://github.com/scalamacros/paradise/issues/61
on 2015-01-17 15:29 *
By Eugene Burmako
"If you keep doing "Eclipse -> Scala -> Restart Presentation Compiler", scala ide might start working, but crashes again after any major edit attempt".
Guys, what could be the reason for such behavior? I'm familiar with the way that batch typer operates, but maybe you could fill me in about how presentation typer is different? Do you sometimes do partial typechecks? Do you sometimes interrupt typechecks in flight and then rerun them?
Guys, what could be the reason for such behavior? I'm familiar with the way that batch typer operates, but maybe you could fill me in about how presentation typer is different? Do you sometimes do partial typechecks? Do you sometimes interrupt typechecks in flight and then rerun them?
on 2015-01-17 16:25 *
By Andrei Pozolotin
one difference I noticed between sbt and eclipse invocations of paradise, is that "info" markers, such as these
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala#L25
show up only once during sbt build in the sbt log, but 1 or 2 or 3 times in the eclipse "Problems View"
probably paradise plugin is invoked multiple times with macro context being expanded again on every invocation?
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala#L25
show up only once during sbt build in the sbt log, but 1 or 2 or 3 times in the eclipse "Problems View"
probably paradise plugin is invoked multiple times with macro context being expanded again on every invocation?
on 2015-01-17 16:39 *
By Andrei Pozolotin
there is one more issue, related to quasiquotes:
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala#L71
there are few issues like these https://issues.scala-lang.org/browse/SI-6877 marked resolved, and the problem is not present in sbt
somehow eclipse brings them back from the dead :-)
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/macros/src/main/scala/macros2/Macros.scala#L71
- ERROR
- too many patterns for trait api: expected 1, found 9
- recursive value x$4 needs type
there are few issues like these https://issues.scala-lang.org/browse/SI-6877 marked resolved, and the problem is not present in sbt
somehow eclipse brings them back from the dead :-)
on 2015-01-17 16:51 *
By Eugene Burmako
I think I've seen the quasiquote problem fixed recently by Jason Zaugg. @jason.zaugg could you comment, please?
on 2015-01-17 17:32 *
By Andrei Pozolotin
additional scala-ide cross version support issue:
if your run scala ide bundled with scala 2.11.5, but use macro project with scala 2.11.4, such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/project/build.scala#L5
then it still crashes presentation compiler, despite the promises http://scala-ide.org/blog/
The crash probably points to version incompatibility:
attempts to use "Eclipse -> Scala -> Set the Scala Installation" to force 2.11.4 runtime , does not help, probably scala ide uses some scala instance internally which is tied to the bundled scala, and not configured runtime
the work around is use scala-ide with bundle scala version which matches the project scala version
if your run scala ide bundled with scala 2.11.5, but use macro project with scala 2.11.4, such as
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/project/build.scala#L5
then it still crashes presentation compiler, despite the promises http://scala-ide.org/blog/
The crash probably points to version incompatibility:
Presentation compiler crashed while type checking this file: java.lang.NoSuchMethodError: scala.tools.nsc.typechecker.Namers$Namer.enterExistingSym(Lscala/reflect/internal/Symbols$Symbol;)Lscala/tools/nsc/typechecker/Contexts$Context;
attempts to use "Eclipse -> Scala -> Set the Scala Installation" to force 2.11.4 runtime , does not help, probably scala ide uses some scala instance internally which is tied to the bundled scala, and not configured runtime
the work around is use scala-ide with bundle scala version which matches the project scala version
on 2015-01-17 17:36 *
By Andrei Pozolotin
here is my step-by-step transcript to reproduce the problem, (confirmed by Eugene Burmako)
start
work directory
mkdir /tmp/macros
setup test project
cd /tmp/macros
git clone git@github.com:carrot-garden/carrot-scala-macro-tester.git
cd carrot-scala-macro-tester
sbt
compile
eclipse
exit
setup scala ide
cd /tmp/macros
wget http://downloads.typesafe.com/scalaide-pack/4.0.0.vfinal-luna-211-20141216/scala-SDK-4.0.0-vfinal-2.11-linux.gtk.x86_64.tar.gz
tar -xvf scala-SDK-4.0.0-vfinal-2.11-linux.gtk.x86_64.tar.gz
cd eclipse
eclipse
import project in eclipse
Eclipse -> File -> Import -> Existing Projects Into Workspace -> /tmp/macros/carrot-scala-macro-tester -> Finish
verify errors on eclipse open after sbt compile
open in eclipse:
carrot-scala-macro-tester-schema/.../macros2/Schema.scala
review error locations:
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L7
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L14
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L41
verify same tool chain versions
versiion1 = Eclipse -> About Scala IDE -> Installation Details -> Scala 2.11.4
version2 = https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/project/build.scala#L6 ### 2.11.4
versiion1 == versiion2
end
start
work directory
mkdir /tmp/macros
setup test project
cd /tmp/macros
git clone git@github.com:carrot-garden/carrot-scala-macro-tester.git
cd carrot-scala-macro-tester
sbt
compile
eclipse
exit
setup scala ide
cd /tmp/macros
wget http://downloads.typesafe.com/scalaide-pack/4.0.0.vfinal-luna-211-20141216/scala-SDK-4.0.0-vfinal-2.11-linux.gtk.x86_64.tar.gz
tar -xvf scala-SDK-4.0.0-vfinal-2.11-linux.gtk.x86_64.tar.gz
cd eclipse
eclipse
import project in eclipse
Eclipse -> File -> Import -> Existing Projects Into Workspace -> /tmp/macros/carrot-scala-macro-tester -> Finish
verify errors on eclipse open after sbt compile
open in eclipse:
carrot-scala-macro-tester-schema/.../macros2/Schema.scala
review error locations:
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L7
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L14
https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/schema/src/main/scala/macros2/Schema.scala#L41
verify same tool chain versions
versiion1 = Eclipse -> About Scala IDE -> Installation Details -> Scala 2.11.4
version2 = https://github.com/carrot-garden/carrot-scala-macro-tester/blob/master/project/build.scala#L6 ### 2.11.4
versiion1 == versiion2
end
on 2015-01-17 17:37 *
By Eugene Burmako
I've just published 2.1.0-SNAPSHOT, which at least allows macro annotations to expand (previously they couldn't do that at all). There are still problems with spurious double definition errors, but at least that's a start.
Speaking of version compatibility problems, I think that things are pretty much hopeless here. If Scala IDE internally runs Scala 2.11.x, and you're using a compiler plugin built against a binary-incompatible 2.11.y, things are going to crash. Please correct me if I'm wrong.
Speaking of version compatibility problems, I think that things are pretty much hopeless here. If Scala IDE internally runs Scala 2.11.x, and you're using a compiler plugin built against a binary-incompatible 2.11.y, things are going to crash. Please correct me if I'm wrong.
on 2015-01-17 17:43 *
By Andrei Pozolotin
1) re: "published 2.1.0-SNAPSHOT" - thank you, checking
2) "Please correct me if I'm wrong" - presumably it is now decoupled; now please you correct me :-)
http://scala-ide.org/blog/
http://scala-ide.org/blog/scala-installations.html
"""
Multiple Scala versions support
This was, without any doubt, the biggest shortcoming of the Scala IDE: support for only one version of Scala in a given installation. Finally, this is no longer the case: Scala IDE can now handle projects with different Scala versions in the same workspace. By default, you get two predefined Scala Installations, one for 2.11 and one for 2.10. You can add more and assign any of them to your project. More details can be found here.
"""
2) "Please correct me if I'm wrong" - presumably it is now decoupled; now please you correct me :-)
http://scala-ide.org/blog/
http://scala-ide.org/blog/scala-installations.html
"""
Multiple Scala versions support
This was, without any doubt, the biggest shortcoming of the Scala IDE: support for only one version of Scala in a given installation. Finally, this is no longer the case: Scala IDE can now handle projects with different Scala versions in the same workspace. By default, you get two predefined Scala Installations, one for 2.11 and one for 2.10. You can add more and assign any of them to your project. More details can be found here.
"""
on 2015-01-17 19:01 *
By Andrei Pozolotin
experimentation with
demonstrates that:
1) "it feels like" presentation compiler crashes less :-)
2) de-compile of target classes confirms that macro expansion happens consistently after eclipse edit/save
3) presentation compiler shows wrong errors, missing type members, etc., but hey! at least you can do some (blind) development now :-)
- scala ide 4.0.0.v-2_11-201501121809-027320c
- scala 2.11.5
- paradise 2.1.0-SNAPSHOT
demonstrates that:
1) "it feels like" presentation compiler crashes less :-)
2) de-compile of target classes confirms that macro expansion happens consistently after eclipse edit/save
3) presentation compiler shows wrong errors, missing type members, etc., but hey! at least you can do some (blind) development now :-)
on 2015-01-21 10:40 *
By Iulian Dragos
Regarding multi-version support: the presentation compiler is always the one that's shipped with the IDE. In 2.11, there's a compatibility flag, -Xsource:major.minor, that lets the compiler work with sources of a previous version. However, this does not extend to macros or compiler plugins. There's a bug in the current release, and we only detect major version mismatches. So, if your macro library is crosscompiled for 2.11.4, but the IDE uses 2.11.5 it will consider it a valid combination (partly because we have no way to know if a library contains macros or not). In such a case, you can add `-Xmacros-expand:none` to the Additional Parameters field in compiler options.
on 2015-01-21 12:30 *
By Andrei Pozolotin
Iulian:
1) re "multi-version support" thanks for clarifying the situation.
2) there is one more issue that needs your clarification for David Bernard: https://github.com/davidB
how m2e can configure scala-ide settings, such as Xplugin? https://github.com/sonatype/m2eclipse-scala/issues/37
1) re "multi-version support" thanks for clarifying the situation.
2) there is one more issue that needs your clarification for David Bernard: https://github.com/davidB
how m2e can configure scala-ide settings, such as Xplugin? https://github.com/sonatype/m2eclipse-scala/issues/37
on 2015-01-22 11:31 *
By Eugene Burmako
Actually, as long as you don't cast to internal, macros are supposed to be compatible within a given major version of the compiler (because scala-reflect.jar is frozen within a major release). 2.11 won't expand 2.10 macros and vice versa, but apart from that, things should work fine.
on 2015-01-24 18:57 *
By Andrei Pozolotin
here is the ultimate use case: please try to make this project work in eclipse: https://github.com/scala/pickling
No file chosen
You have an empty file field. Please select or remove it.
Name | Size |
---|