It is true that implicits can degrade compilation speed, especially for code that uses them for level-level computing. It is definitely worth evaluating their impact. Unfortunately, it can be difficult to track down criminals. There are tools that can help:
Run scalac with -Ystatistics:typer to see how many tree nodes are processed during type checking. For instance. you can check the number of ApplyToImplicitArgs and ApplyImplicitView against the total number (and maybe compare this to a different code base).
Scala Center efforts are currently being strengthened to improve the status quo hosted on scalacenter / scalac-profiling . It includes an sbt plugin that should be able to give you an idea of โโimplicit search time, but it is still in its infancy (not yet published at the time of writing). I have not tested it myself, but you can still try it.
You can also compile with -Xlog-implicits , transfer the output to a file, and analyze the logs. It will display a message for each implicit candidate that has been reviewed but not completed, complete with its original position, search type, and reason for failure. Such unsuccessful searches are expensive. You can write a simple script with your favorite scripting language (why not Scala?), To summarize the data and even draw it using some nice graphics.
Also: how to allow a specific implicit instance?
Just use reify and good println debugging:
import scala.collection.SortedSet import scala.reflect.runtime.universe._ println(showCode(reify { SortedSet(1,2,3) }.tree))
source share