IntelliJ IDEA 2017.2 Help

Working with Scala Implicit Conversions

The following is only valid when Scala Plugin is installed and enabled!

Scala implicit conversions is a powerful tool for Scala coding. It lets you decrease redundancy in your code and lets you make the code easier to read.

Implicit Conversion Highlighting

If Scala type-aware highlighting type aware highlighting icon is enabled then IntelliJ IDEA highlights methods that are added via implicit conversions with a grey underline:

grey underline

Invoking Implicit Conversion Methods

  • Select an expression and press Shift+Ctrl+Q (Ctrl+Q for macOS) to invoke the list of applicable implicit conversions. The list shows the regular scope displayed on the top and the expanded scope that is displayed on the bottom of the list.
    choose implicit conv
  • You can make the implicit conversion method explicit. Press Alt+Enter and select Make explicit or Make explicit (Import method):
    choose implicit with make exp
  • If you select Make explicit then IntelliJ IDEA returns a method call with the class name. It might be helpful if you need to make sure that the compiler imports the particular implicit conversion method that you originally wanted:
    make explicit
  • If you select Make explicit (Import method) then the method is imported statically and IntelliJ IDEA returns just its call without the class name. Also, the next time you open the list of useful implicit conversions you will see this method in the regular scope:
    make explicit import met

Invoking Implicit Parameters

  • Place a cursor to the method where implicit conversion was used and press Ctrl+Shift+P to invoke implicit parameters. It might be helpful for code analyzing when you want to find out what implicit parameters were passed to the particular call. IntelliJ IDEA also lets you view the recursive implicit parameters.
    implicit param
  • If IntelliJ IDEA cannot find method calls where implicit parameters were passed, it displays a pop-up message:
    no implicit param
Last modified: 29 November 2017