Uniqus
Uniqus

Reputation: 574

How to know the place Scala implicit definition come from?

I developed a class that takes an implicit engineProvider: ClientSSLEngineProvider as a constructor parameter. When I instantiate the class, I don't have any implicit definition of such type anywhere within my source file, however the code compiles without any errors. When I use debugger, I can see that this parameter is initialized with some value. It looks like this implicit is defined somewhere else (in one of the imports).

How can I locate the exact place where it is defined? I'm using IDEA for development, if it matters.

Upvotes: 3

Views: 1361

Answers (2)

Eugene Zhulenev
Eugene Zhulenev

Reputation: 9734

If you are using sbt add this line into your build.sbt build file.

scalacOptions in ThisBuild += "-Xlog-implicits"

I'd also suggest you to take a look at the companion object of ClientSSLEngineProvider (it's one of default sources for implicits)

Upvotes: 10

som-snytt
som-snytt

Reputation: 39577

Maybe just use -Xprint:typer to see what was used:

$ scala -Xprint:typer

scala> Future(1)

     private[this] val res0: scala.concurrent.Future[Int] = scala.concurrent.Future.apply[Int](1)(scala.concurrent.ExecutionContext.Implicits.global);

Upvotes: 5

Related Questions