Search code examples
scalaintellij-ideadottyintellij-scalascala-3

IntelliJ suddenly stops highlighting errors in Scala/Dotty project


TLDR; IntelliJ isn't highlighting any errors (syntax/type mismatch) in my Scala project. I've tried type-aware highlighting, setting highlighting level to "Inspections", and enabling "Experimental Features" according to StackOverflow answers, and reloading the project.

I have a Scala 2.13 project (sbt) that was working just fine in IntelliJ 2019.3. I made some changes after that (I did not check to see if it compiled, and it had several errors in it) and then I decided to port it to Dotty (and also updated IntelliJ to 2020.1 EAP). I created a new Dotty project, which obviously had no errors.

I then copied all my source files to this project and modified the build.sbt file. When I did this, I could see a few syntax errors highlighted, and the given keyword was not detected as a keyword, most likely because the plugin thought the language was supposed to be Scala 2, not Scala 3.

After that, I imported the project from sbt, and the wrong syntax errors disappeared, so I happily closed that file and started fixing the others. I'm not sure if error highlighting was working at first and then turned off, or if it never worked. After a while, I realized that unresolved references weren't highlighted - for example, when I mispelled a class name and tried to go to the declaration, it didn't do anything, although when I corrected it, it could resolve the reference, presumably because that was one of the files that had no errors. Then I saw that syntax errors weren't recognized either.

I have type-aware highlighting enabled, and the highlighting level is set to inspections. I am using IntelliJ 2020.1 EAP with Scala plugin build 2020.1.977 (EAP). The build.sbt contains scala version "0.23.0-RC1". IntelliJ wasn't running any other processes, and there weren't any resource-intensive programs on my computer at the time.

I got multiple error messages at the bottom right, such as

  • java.lang.AssertionError: assertion failed (A couple times)

  • com.intellij.psi.PsiInvalidElementAccessException: Element: class org.jetbrains.plugins.scala.lang.psi.impl.statements.params.ScTypeParamImpl #Scala because: different providers: org.jetbrains.plugins.scala.lang.psi.ScFileViewProvider{vFile=file:<The path>/Pattern.scala, content=VirtualFileContent{size=1716}, eventSystemEnabled=true}(a24437); org.jetbrains.plugins.scala.lang.psi.ScFileViewProvider{vFile=file:<Same path>/Pattern.scala, content=VirtualFileContent{size=1716}, eventSystemEnabled=true}(b39181a) invalidated at (This one came up several times)

I have a feeling this is just a bug with Dotty that will be resolved soon. The Scala Nightly plugin had similar behavior, which is why I switched to EAP and also created an entirely new project, which I assumed would be less buggy. Any suggestions would be really appreciated.

The same thing is happening with my old Scala 2 project also when I open it in IntelliJ 2020.1 EAP but not in 2019.3. It now seems it's not a Dotty-specific thing.


Solution

  • Dotty oficialy is not supported yet because its syntax is not frozen, a thing like optional braces is being changed now. The only place where everything works relatively fine is an official vscode, and it used by compiler devs. So, if you want to play with dotty, a vscode and all the env probably would be your choice: https://dotty.epfl.ch/docs/usage/ide-support.html