I used such a line to test my implications, which makes it implicit with copy-paste. It took me a while to figure out why this compiles, even though I did not expect it to compile:
> console [info] Starting scala interpreter... [info] Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_66). ... skipped some comment lines ... scala> case object Foo defined object Foo scala> object Bar { implicit val f: Foo.type = implicitly[Foo.type] } defined object Bar scala> val x = Bar.f x: Foo.type = null scala>
I would expect Bar to complete the compilation because there is no implicit val type Foo.type (the case object is NOT declared implicit).
It seems to me that the compiler uses its own declaration (left) to complete its implementation (right side).
Is this really intended behavior? At runtime, this leads to unexpected behavior with null values ββ(mostly for NPE for me).
source share