Scala logo

Scala Plugin

Scala Plugin for IntelliJ IDEA and Android Studio

News

Type-aware highlighting

Type-aware highlighting is a part of error highlighting that relies on type system.

Some errors can be found without using type information, for example:

Other errors, however, require a knowledge of entities type:

Type-aware highlighting allows to spot such errors before compilation.

Why isn’t it enabled by default?

The feature is in beta (or maybe in alpha) and sometimes may report “false errors” in regular code. Usually, such “errors” “found” only in a truly complex code, and, normally, everything works just fine.

Scala plugin doesn’t rely on compiler to analyze code. We’re implementing our own model of the language, and sometimes it’s challenging, especially when it comes to Scala’s type system and type inference (to size up the problem, you may try to formally “infer” a type of “foo”.map(_ + 1) expression by hand).

Should you enable it?

Unless such highlighting produces too much false “red code” in your project, you can benefit from better code analysis. It’s recommend to try type-aware highlighting in a particular project to evaluate whether it’s good there.

How to configure it?

In every project (with at least one Scala facet used) IDEA initially suggest to try type-aware highlighting, so you may configure it right off the bat:

You can always toggle type-aware highlighting using Ctrl+Alt+Shift+E shortcut or by clicking the highlighting icon on statusbar:

There’s a notification shown on each highlighting status change:

How to deal with false errors?

So, the truth is you have to remember that sometimes there’s no spoon error.
To help us to fix a highlighting glitch you may report it to YouTrack as usual or by pressing Alt+Enter on wrong highlight: