I can see java compilation error immediately on the project tree, but for scala code, I could not see that. Anyone know how to achieve that ?
Related
I changed my Scala version from 2.10.x to 2.11.8. I am getting some compilation issues. I tried, but still not able to resolve because I am poor in Scala and sbt.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
What might be the issue here?
I resolved this issue but it not a single thing, I did couple of things:
First I gone through the error location in WebService.scala.
Then to the corresponding "Logger" class.
I check from which jar that "Logger" class coming.
I found that it referring to some thing else jar than what I am expecting.
That jar is coming from one of my dependent project (modules) so in build.sbt, those dependent jars I excluded that wrong jar which I found.
After I changed the code in WebService.scala, I removed that import for logger and added new import having Logger what I expecting. I did same all the other places in my project.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
This is not particular to logger issue. If you are getting "can't expand macros compiled by previous versions of Scala" issue", you have to do same procedure for corresponding to your error (my case logger).
First time, I search online regarding this issue, I found same issue facing lot of people, but different library classes (I face Logger class issue).
I am learning Scala and I am using typesafe activator to run the programs. I have my first program in the below path <downloads>\typesafe-activator-1.3.7\activator-dist-1.3.7\simple scala project\scala-2.11\Simple_scala_project.scala
Below is the program content
object Simple_scala_project {
def main (args:String): Unit =
{ println("My first scala program") }
}
when I am running the below command in the command line I am getting the error
scala -cp <downloads>\typesafe-activator-1.3.7\activator-dist-1.3.7\simple scala project\scala-2.11 Simple_scala_project
:1: error: ';' expected but double literal found.
Please help me in this.
I noted a similar error when I inadvertently placed a line including "sbt.version=1.3.13" (in my case) in the wrong file. I realize now that it should have gone into a folder insider my overall project folder called "project", inside a file called "build.properties" (instead of in "build.sbt").
The take-away from this is that I don't think you experienced a compiler error at all, but an error owing to some files in the project setup. Better SBT documentation may be found here.
It's absolutely true that SBT isn't needed for very simple examples, and indeed offends the sensibilities of ones volunteering to learn a new language (soon to be improved, Scala 3.x, not a hundred other extraneous technologies. I find IntelliJ Idea Community to be a boost, here, since its Scala support is first-rate, and will create simple example projects for you in a variety of ways Installing Scala / Installing Scala plugin for Idea.
I'm currently giving the IntelliJ Scala plugin a spin and one thing is bugging me a wee-bit. I get 3 warnings when compiling.
Warning: scala: Recompiling 4 files
Warning: scala:
Warning: scala: there were 1 deprecation warnings; re-run with -deprecation for details
Why does it give me warnings that files are being recompiled? Can that be turned off? And finally, what's with the empty warning? :D
In IntelliJ 14:
Bring up preferences Intellij IDEA > Preferences or cmd + ,
Look up Scala Compiler. Alternatively, it's under Build, Execution, Deployment > Compiler > Scala Compiler
Check the option for Deprecation warnings
Rebuild your project!
I would like to add few words about warnings and errors reported by IntelliJ IDEa.
JetBrains uses it's own scala analyzer to identify and report errors. Sometimes it reports fake errors or warnings. I think this is because scala is much more complicated language from compilers point of view then much of other languages. Even if all official scala specification was implemented there are some cases which have been omited (read: There always are some bugs). If you find something reported as error/warning by your IntelliJ IDEa which is ok for scalac compiler you can always try to report it as a bug (IntelliJ IDEa supports reporting bugs). Guys from JetBrains will fix it.
More over some scala libraries use macros that are compiler extentions which adds some extra compiler behaviour. If IDE did know their specification it wouldn't identify these non standard codes as errors. It's better to be aware of that. I think the same touches Eclipse scala IDE.
Summarizing all above:
Do not trust all warnings and errors that IntelliJ or other IDE is telling you unless it compiles well using scalac.
JVM parameters isn't compiler parameters -- first are used to actually run your code, later used to just compile it to bytecode. You need to open project settings and adjust options there:
I'm trying to develop on the Scala compiler project with the help of ScalaIDE. I followed this guide to set up the development environment. When I now try to build the mentioned projects, the reflect project won't get built. Instead, I get the following error via the console output:
uncaught exception during compilation: scala.reflect.internal.MissingRequirementError reflect Unknown Scala Problem
Having tried the provided ANT script of the project via the console, everything seems to work fine.
Does anyone know if I'm missing a hidden compiler flag, dependency or something like this?
Thanks!
With the IDE for Scala 2.10 you can only build the 2.10.x branch of the Scala compiler. If you want to work on master, you need to install a 2.11-based version of the IDE. We don't publicise IDE for 2.11 nightlies yet, but they are available at:
http://download.scala-ide.org/nightly/scala-ide-master-2.11.0-SNAPSHOT/
I'm trying out Intellij on a mixed Java/Scala project. Build is failing with errors like this:
Error: scala:
/home/kevin/ij/backend/srctest/com/example/package/DoStuffTest.java:35:
warning: [deprecation] OldStuffList in com.example.package has been
deprecated
I'm not able to find any setting related to treating warning as errors. I'd like these to be reported as warnings (because indeed, they are warnings), but not prevent the build from completing.
In the scala compiler settings, check that there is no -Xfatal-warnings
This option makes scalac treat warning as error.
Note that I had this problem after a colleague added this option in the build.sbt of an sbt project. Intellij then added it to its scala compiler settings.
If you hit alt-enter on the highlighted error, it should at least give you a dropdown option called "Disable inspection" which should let you turn that off for that instance or all Deprecated errors. This doesn't really solve your problem, but it might at least get you past it.