Skip to main content

Command Palette

Search for a command to run...

Scala Compiler Implicit Parameter Precedence

Published
•1 min read•View as Markdown
S

I'm to shy to write smth about me For now

The compiler doesn’t randomly look for implicits in your code; it follows the following precedence:

  1. Locally declared implicits
  2. Imported implicits
  3. Outer scope (ex- a class for a method)
  4. Inheritance
  5. Package object
  6. Implicit scope like companion objects

Source: Top 30 Scala Interview Questions