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:
Related
Using the Cats library for Scala in IntelliJ IDEA leads to errors even if terminal SBT works. Can we fix this? Or some workaround that isn't switching editor?
Cats seems to work fine on my IntelliJ 2018.1.4. If it is working in the terminal but not in IntelliJ, it could be because of using in-built IntelliJ compiler. Have you tried enabling Use sbt shell for build and import, which delegates building to SBT:
Open sbt projects tool window: View | Tool Windows | sbt
Click sbt settings icon
Select Use sbt shell for build and import (required sbt 0.13.5+)
Use sbt shell might resolve compilation issues, however note that in-editor error highlighting might still give false positives because it uses custom-built typechecker.
Metals is an alternative that uses Scala proper for both compilation and in-editor error diagnostics.
In IntelliJ (version: 2016.3.1, Scala Plugin version: 2016.3.5), I have a Scala 2.12 (which implies Java 1.8 being required) project where I am selecting "Build/Rebuild Project". I am receiving the following output in the "Messages" windows:
Warning:scalac: there were four deprecation warnings (since 2.12.0); re-run with -deprecation for details
What steps must I take to configure my project such that I can actually see the content of the 4 warnings?
I found another question for IntelliJ 14 which showed how to turn on deprecation warnings, but didn't indicate how to surface the actual content of the deprecation warnings themselves. Any guidance on this would be greatly appreciated.
Add the following to your sbt build file:
scalacOptions += "-deprecation"
As of the latest Intellij version at this time, you can also open Settings -> Build, Execution, Deployment -> Compiler -> Scala Compiler, and in Additional compiler options:, append -deprecation.
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.
I know I must be missing something, but can't figure out what. When I create a scala project, following the scala-plugin instructions, not a single syntax error is detected. For example:
object MyApp {
val aNumber: Int = "hello"
}
does not detect any error. If I right-click and ask it to compile, then I get the expected type mismatch error from the scala compiler. This is just a silly example, no syntax errors are being flagged. For regular Java projects it works fine, so it must be scala specific.
I have a clean install of IDEA 10 CE on a OSX 10.6 and Scala 2.8.1 final. I have set up the jdk in the project settings as well as the scala home when creating the project. I have the latest version of the plugin (12/2010).
Any hint on what I'm missing?
You have to enable error highlighting. Turn on Settings/Code Style/Scala/Other settings/Enable experimental error highlighting
Works here too (IntelliJ 10.0.1, Scala 2.8.1, OpenJDK, Ubuntu 10.10 64bit).
If you want more type checking you can also tick "Enable experimental error highlighting (possibly shows many wrong red code)" in the Settings, but this shouldn't make a difference in your case, although it works perfectly in my case for a large code base.
In project structure > modules > [your project name] > dependencies tab, do you have scala-compiler-[some version] listed?
See the Exploring the Project Structure here
intelliJ IDEA 10.0.1 + scala 2.8.1 on Ubuntu 10.10 64bit.
It shows a type mismatch error
For 2019.1 CE on Mac OS:
Preferences | Build, Execution, Deployment | Compiler | Scala Compiler
Checked the option:
Features->Experimental Features