Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala warnings, IntelliJ and compiler flags

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

like image 657
JustDanyul Avatar asked Oct 25 '13 09:10

JustDanyul


People also ask

Does IntelliJ work with Scala?

To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.

How do I add Scala framework support in IntelliJ?

To add Scala support to existing module: Right-click the module in Project View, choose “Add Framework Support…” Check “Scala” in technologies list (unavailable if module has Scala facet attached) Provide a path to Scala installation (if not detected)

What compiler does IntelliJ use?

IntelliJ IDEA comes bundled with the Eclipse compiler. Groovy-Eclipse.


3 Answers

In IntelliJ 14:

  1. Bring up preferences Intellij IDEA > Preferences or cmd + ,
  2. Look up Scala Compiler. Alternatively, it's under Build, Execution, Deployment > Compiler > Scala Compiler
  3. Check the option for Deprecation warnings

Rebuild your project!

Screenshot of preferences to enable deprecation flag.

like image 51
katfang Avatar answered Oct 16 '22 09:10

katfang


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.

like image 32
pawel.panasewicz Avatar answered Oct 16 '22 09:10

pawel.panasewicz


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:

enter image description here

like image 39
om-nom-nom Avatar answered Oct 16 '22 10:10

om-nom-nom