Search code examples
scalaimplicitsimplicit-conversion

Which implicit conversions in Scala are present as default when nothing is imported


Which implicits are present by default in Scala?

I know of RichString, Regex and some others I use.

  • But is there a list of them all?
  • Where are they implemented ? SourceFiles?
  • Is there a way to get a list of all possible implicit conversions for the current state of imports ?

Solution

  • The automatically imported members are:

    • The members of the java.lang package
    • The members of the scala package
    • The members of the Predef object

    See The scala specification §9.1

    Given that only objects (and package objects) can contain methods or values, the only place where standard (with no additional import) implicit values can be found is in Predef (the scala package does not seem to have a corresponding package object at the moment).