how to find the implicit function or variables in scala

前端 未结 2 1919
一个人的身影
一个人的身影 2021-01-02 17:27

I can\'t find the implicit conversions or implicit argument values being used in Scala code. This makes reading open source projects very confusing.

The implic

相关标签:
2条回答
  • 2021-01-02 17:55

    One trick that has been covered on SO:

    scala> import reflect.runtime._,universe._
    import reflect.runtime._
    import universe._
    
    scala> reify { "abc".size }
    res1: reflect.runtime.universe.Expr[Int] = Expr[Int](Predef.augmentString("abc").size)
    

    Recent REPL:

    scala> 3 until 4 //print<hit tab completion>
       scala.Predef.intWrapper(3).until(4) // : scala.collection.immutable.Range
    
    0 讨论(0)
  • 2021-01-02 18:14

    You can also use the Scala Plugin for IntelliJ IDEA. The implicit conversions are underlined like this (where Int 1 is converted to BigInt):

    The above example is taken from https://www.jetbrains.com/help/idea/2016.1/working-with-scala-implicit-conversions.html?origin=old_help#highlight. You can read more on that page.

    0 讨论(0)
提交回复
热议问题