| Welcome to Scala 2.12.0-M5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). | |
| Type in expressions for evaluation. Or try :help. | |
| scala> case class Foo(x: Int) | |
| defined class Foo | |
| scala> object Bar { | |
| | implicit val foo: Foo = Foo(1) | |
| | object Baz { | |
| | implicit val foo: Foo = Foo(2) | |
| | println(implicitly[Foo]) | |
| | } | |
| | } | |
| defined object Bar | |
| scala> Bar.Baz | |
| Foo(2) | |
| res0: Bar.Baz.type = Bar$Baz$@7ff35a3f | |
| scala> object Bar { | |
| | implicit val foo: Foo = Foo(1) | |
| | object Baz { | |
| | implicit val foo2: Foo = Foo(2) | |
| | println(implicitly[Foo]) | |
| | } | |
| | } | |
| <console>:17: error: ambiguous implicit values: | |
| both value foo in object Bar of type => Foo | |
| and value foo2 in object Baz of type => Foo | |
| match expected type Foo | |
| println(implicitly[Foo]) | |
| ^ | |
| scala> :quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment