E061: Top Level Can't Be Implicit
This error was made inactive in Scala 3.0.0 because top-level implicits are now allowed.
This error was triggered when attempting to define an implicit value or method at the top level of a source file.
Example
package example
implicit val x: Int = 42 // error in old versions
Error
-- [E061] Syntax Error: example.scala:2:0 --------------------------------------
2 |implicit val x: Int = 42
|^
|`implicit` modifier cannot be used for top-level definitions
Explanation
In earlier versions of Scala 3, implicit definitions were required to be inside a class, object, or trait. This restriction was removed.
Since Scala 3.0.0 (specifically after PR #5754), top-level implicits are allowed and work correctly:
// This now works in Scala 3
implicit val x: Int = 42
// Or using the modern given syntax
given Int = 42
In this article