Features Releases

IntelliJ Scala Plugin 2019.2: Functional Code Highlighting, Fine-grained Type Diff, Case Clause Completion, Build Server Protocol, and More

The 2019.2 release of the Scala plugin offers many improvements in different areas. The key focus of this release is a new code highlighting paradigm whereby the highlighting is now cleaner, yet provides even more coding assistance.

1. Functional code highlighting
2. Fine-grained type diff
3. Interactive type hints
4. Wrap / unwrap expressions as you type
5. Unobtrusive redundant code inspections
6. Case clause completion
7. Build Server Protocol
8. Language injection for multiline strings
9. Duplicate code fragment inspection

Functional code highlighting

Previously, IntelliJ IDEA highlighted type mismatch errors with a red squiggly underline. But long underlines are hardly pretty, especially if they span across multiple lines. Outer errors mask inner errors. And if you’re in the process of writing such an expression, it would be constantly underlined solely for being incomplete.

Now we can do better: instead of underlining the whole expression, the Scala plugin now shows a type ascription hint and highlights only the part that doesn’t match the expected type:

This significantly cleans up your editor, while providing even more coding assistance. To learn about the “whys” and the “hows”, see our recent post, Functional Highlighting for Functional Programming. (Note that the mode is controlled by Settings | Languages | Scala | Type mismatch highlighting.)

Fine-grained type diff

Previously, we compared types as indivisible units. While technically this wasn’t wrong, it was hardly convenient, because you had to “parse” and “type-check” the constituent types in your head to understand why exactly the types did not match.

Now we can show a fine-grained, vertically-aligned tooltip for a pairwise comparison:

It’s not just a text-based diff – the algorithm takes syntactic sugar, subtyping, variance, and other tricky stuff into the account.

Interactive type hints

Type annotation hints now support dynamic folding, tooltips, navigation, and brace matching:

What’s more, type hints are shown only when they are truly needed (so, if you previously disabled type hints because they were too noisy, consider giving them another try). That’s the second editor cleanup, alongside with the new type mismatch highlighting.

Wrap / unwrap expressions as you type

Before, you had to invoke the Add braces around single line intention to wrap an expression in curly braces, or the Remove braces intention to unwrap an expression.

Now, IntelliJ IDEA can do that automatically, as you type:

While the intentions are still available (and work just fine), the automatic balancing is much more discoverable and is very handy in practice.

Unobtrusive redundant code inspections

IntelliJ IDEA has always highlighted unused imports or unreachable code as “unused” (as defined by the Color Scheme). Other things, however, were highlighted as “generic warning or error”, which polluted code and concealed actual errors.

Now we highlight all redundant code uniformly, so that the highlighting looks unobtrusive:

That’s the third editor cleanup. Since the highlighting now doesn’t get in your way, we can implement many more useful related inspections. Feel free to vote for the ones you like the most!

Case clause completion

The Scala plugin has already offered exhaustive match completion for quite some time.

Now you can also complete individual case clauses:

What’s more, the completion now works in partial functions, as well as in match expressions.

Build Server Protocol

The Build Server Protocol (BSP) defines a standard way for build tools to talk to IDEs, allowing you to open projects, run compilation, perform tasks, display error messages, and monitor progress updates directly in the IDE.

For a while, BSP support was an experimental feature, but not anymore – now it’s fully supported:

The supported build tools include Bloop and Fury so far. Support for Mill is coming soon. We’re going to post more details on the BSP integration soon, so stay tuned.

Language injection into multiline strings

Now let’s talk about a few features that are only available in IntelliJ IDEA Ultimate. The first one is the support of language injection into multiline strings:

This feature may come handy for embedding SQL, HTML, or JavaScript into Scala code.

Duplicated code fragment inspection

Did you read the HTML comment in the previous release announcement? If you didn’t, here it is again: “We’ve also implemented duplicates detection, but this capability is not yet enabled in the IntelliJ Platform; expect that feature in the next release”. So, here goes:

Because the feature is implemented as an inspection, you can invoke Run inspection by name | Whole project to fix all the duplicates at once. The algorithm can filter out whitespaces, syntactic sugar, and other accidental details. So, don’t repeat yourself, don’t repeat yourself.


The new features work in synergy with the implicit hints, which have already cleaned the editor from pervasive “implicit underlines”. The Scala plugin now offers a unique combination of clarity and power: your code looks almost as clean and unclouded as in a plain text editor, while you have intelligence that even the Scala compiler can’t provide, including implicit hints, fine-grained type diffs, inspections, and much more.

Your feedback is very welcome as always. Please report any bugs to YouTrack so that we can fix them as soon as possible. Thank you!


The IntelliJ Scala plugin team

Comments below can no longer be edited.

8 Responses to IntelliJ Scala Plugin 2019.2: Functional Code Highlighting, Fine-grained Type Diff, Case Clause Completion, Build Server Protocol, and More

  1. Avatar

    Ahmad says:

    July 24, 2019

    Wow, awesome feature additions! Thank you for the hard work!

  2. Avatar

    Krunoslav Uzelac says:

    July 25, 2019

    Awesome work guys!

  3. Avatar

    Daniel X says:

    July 27, 2019

    Great stuff! but … can someone please fix the Scala Worksheets? Or remove them as a feature if they are no longer supported?

    (Short version: The only way to get the worksheet to pick up my compiled changes, is to restart IDEA. Then everything works fine, until I make any code changes in the imported packages. Those changes aren’t visible to the worksheet until the next restart.)

  4. Avatar

    Daniel X says:

    July 27, 2019

    (sorry for the duplicate comment, was getting an nginx error and assumed it didn’t work the first time)

  5. Avatar

    Artur Gajowy says:

    July 27, 2019

    Awesome! Does the duplicate inspection work when using BSP/bloop? I’ve done “Run inspection by Name…”, typed “duplicate” in the search box, but I can’t find an inspection named “duplicated code fragment”, and the only Scala inspection in results is “Argument duplicates corresponding parameter default value”…

    • Avatar

      Nikolay Tropin says:

      July 27, 2019

      Inspection name is “Duplicated code fragment”. It is “General” inspection not limited to Scala.

    • Avatar

      Pavel Fatin says:

      July 27, 2019

      Duplicate Code Fragment is a non-Scala-specific inspection and is only available in IntelliJ IDEA Ultimate.

Discover more