1

I am using IDEA 2017.2.5 to develop in Scala with the SBT plugin. I've been unable to get Scala's code inspection to work correctly. I get lots of seemingly arbitrary errors on valid Scala code, such as "Cannot resolve symbol" or "Type mismatch". Also, lots of imports which I'm definitely using are marked as unused and grayed out.

For example, the following code resolves to " world" but produces a "Cannot resolve symbol toLowerCase" error:

val s = "Hello, World".split(",").last.toLowerCase

I have tried File -> Invalidate Caches / Restart, reinstalling the SBT plugin, using different Scala versions, with no luck. Turning off type-aware highlighting makes some of the errors go away, but not all of them.

The following SO posts seem similar:

How can I resolve this?

web
  • 192
  • 2
  • 12

1 Answers1

1

If you only recently upgraded your project after using IntelliJ for some time, you might want to force it to regenerate its index by removing your .idea folder and re-importing the project. I've had some luck in the past with this trick.

If you want to make sure not to mess anything up, rename the folder instead of removing it:

> cd /path/to/project
> mv .idea .idea-backup

In case of problems, you can always rename .idea-backup back into .idea.

francoisr
  • 4,407
  • 1
  • 28
  • 48
  • I did recently begin using IDEA for Scala after using it exclusively for Java. I tried your suggestion but still get the same errors :/ – web Nov 18 '17 at 18:37
  • Are some of the Scala features available at all? For example, can you import collections like `List` and use them? – francoisr Nov 18 '17 at 19:11
  • Yes. I'm developing a Scala project with both core lang and 3rd party libraries. The SBT shell in IDEA works fine, it's just code inspection that's failing. – web Nov 18 '17 at 19:13