11

One fine day IntelliJ started highlighting my working Scala code in red. While following commands run without a hitch, IntelliJ thinks that code is full of errors an missing a lot of dependencies.

  • sbt clean
  • sbt reload
  • sbt update
  • sbt compile
  • sbt assembly

It reports a lot of Cannot resolve symbols in imports, classes and method-calls on objects like the following. Moreover, it thinks a lot of imports are unused (for the symbols that it can't find) enter image description here

Interestingly, all this is happening in only one of my projects (that contains two submodules inside parent module), while other Scala projects (including those containing submodules) are working fine.

Things that I've tried without luck:

  • Delete (rm -rf) build-related directories like .idea, target, ~/.ivy2/caches
  • Invalidate Caches / Restart...
  • Update IntelliJ IDEA and Scala plugin to latest versions
  • Close and re-import the project, quit IntelliJ, reboot the PC (!)

I'm using:

  • IntelliJ IDEA 2017.3.2 (Community Edition)
  • Build #IC-173.4127.27, built on December 25, 2017
  • JRE: 1.8.0_152-release-1024-b8 x86_64
  • JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  • Mac OS X 10.13.2

My project configurations are:

  • Scala v2.11.11
  • SBT v1.0.3

Once again, I'd like to remind that my Scala code is completely functional and that I'm able to run the JAR generated by sbt assembly elsewhere without an issue.

y2k-shubham
  • 10,183
  • 11
  • 55
  • 131
  • 1
    I would suggest to raise this question with JetBrains support directly, IntelliJ well known for these kind of issues. – Pavel Jan 15 '18 at 13:13
  • Are you able to provide a project or steps that reproduce the issue? Ideally report them on https://youtrack.jetbrains.com/issues/SCL – Justin Kaeser Jan 15 '18 at 13:24
  • Here's the [link](https://intellij-support.jetbrains.com/hc/en-us/community/posts/205997079/comments/360000001364) to the related issue on `JetBrains` Forums (`YouTrack`) – y2k-shubham Mar 13 '19 at 01:27

2 Answers2

2

This solution worked for me: Why does intellij IDEA highlight build.sbt?

Go to the menu: File > Invalidate Caches/Restart

vejeta
  • 133
  • 11
0

Such things happen when project SDK is not set. Also make sure that you have Add Framework Support -> Scala enabled.

streetturtle
  • 5,472
  • 2
  • 25
  • 43
  • 1
    But the list of frameworks does not include Scala. Please read the comments on [this answer](https://stackoverflow.com/a/13723282/3679900) by @sourcedelica – y2k-shubham Jan 16 '18 at 04:33