1

Trying to understand akka marshalling/unmarshalling and found a lot of scala implicit magic that goes on in the background and under the hood.

Question: Is there a way to find which implicit constructs are effective during an execution. Things that would be useful to know: - what implicit declarations and conversions are effective - where they are declared

What I'm thinking is an IDE plugin for this may be? To be used during code debug?

I think this would help in understanding akka marshalling/unmarshalling but also it would be useful generally wherever complex implicit features are used.

jakstack
  • 2,143
  • 3
  • 20
  • 37
  • Not exactly an answer but I find e.g. `reflect.runtime.universe.reify("1".toInt).tree` in a REPL to be super useful. – Travis Brown Jan 06 '19 at 11:03

1 Answers1

1

Implicits are selected at compile time.

With -Xlog-implicit-conversions:

scala 2.13.0-M5> "42".toInt
                 ^
                 applied implicit conversion from String("42") to ?{def toInt: ?} = implicit def augmentString(x: String): scala.collection.StringOps
res0: Int = 42

scala 2.13.0-M5> "42".toInt //print<TAB>
   scala.Predef.augmentString("42").toInt // : Int

-Xlog-implicits explains when implicits do not apply.

IntelliJ has "show implicits".

som-snytt
  • 39,429
  • 2
  • 47
  • 129