Take a look at Predef.intWrapper(Int): RichInt
This is inherited by Predef from LowPriorityImplicits . Inherited implications have lower priorities than non-inherited ones.
Please note that while looking at the source of the library, you really do not see the conversion. The best way to see it in a small snippet is to compile it (or run in REPL) using the -Xprint:typer . This will show the conversion that is inserted by the type so that the code compiles when the types do not match:
$ scala -Xprint:typer scala> 3.abs [[syntax trees at end of typer]]// Scala source: <console> // stuff removed private[this] val res0: Int = scala.this.Predef.intWrapper(3).abs; // more stuff removed }
huynhjl
source share