This document outlines several complementary approaches for statically analysing Scala implicits in IntelliJ.
JetBrains provides a document explaining the first two steps, but does not include the clarification around analysing enriched objects.
Note: These shortcuts are for OSX.
-
Highlight the implicitly converted object.
Important: When investigating an enriched object, you MUST highlight the object only, NOT the injected method. This is because the object is what's being converted; selecting the method will resolve implicit conversions on the object returned by that method.
-
CTRL
+Q
-
Highlight the method call-site.
-
CMD
+SHIFT
+P
See Viewing code without implicits if you receive 'Parameter not found'
The following requires temporary code modification:
-
Perform steps in Viewing implicit conversions.
-
Highlight appropriate implicit conversion function.
-
ALT
+ENTER
(and thenENTER
to select 'Make explicit'). -
Perform steps in Viewing actual implicit parameters.
This is the last resort: it displays the 'unravelled' Scala code, which is useful if you don't have IntelliJ or IntelliJ is unable to resolve implicit parameters:
-
Run from the command line:
sbt "set scalacOptions in Compile += \"-Xprint:typer\"" "compile"
-
Ignore the initial output.
-
'Touch' the file you are interested in.
-
Re-run step 1.