IntelliJ IDEA 2017.1 Help

Working with Scala Implicit Conversions

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 /help/img/idea/2017.1/type_aware_highlighting_icon.png is enabled then IntelliJ IDEA highlights methods that are added via implicit conversions with a 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.
  • You can make the implicit conversion method explicit. Press Alt+Enter and select Make explicit or Make explicit (Import method):
  • 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:
  • 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:

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.
  • If IntelliJ IDEA cannot find method calls where implicit parameters were passed, it displays a pop-up message:
Last modified: 18 July 2017