Skip to content

Instantly share code, notes, and snippets.

@clhodapp
Last active January 24, 2016 18:35
Show Gist options
  • Save clhodapp/d74b050d7f046ccbe3b3 to your computer and use it in GitHub Desktop.
Save clhodapp/d74b050d7f046ccbe3b3 to your computer and use it in GitHub Desktop.
Welcome to Scala 2.12.0-M3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions for evaluation. Or try :help.
scala> :paste
// Entering paste mode (ctrl-D to finish)
trait Foo[A]
object Foo {
@annotation.implicitAmbiguous("Custom ambiguous message")
implicit def a = new Foo[String] { }
implicit def b = new Foo[String] { }
implicit def c = new Foo[String] { }
}
trait Bar[A]
object Bar {
implicit def a = new Bar[String] { }
implicit def b = new Bar[String] { }
@annotation.implicitAmbiguous("Custom ambiguous message")
implicit def c = new Bar[String] { }
}
// Exiting paste mode, now interpreting.
defined trait Foo
defined object Foo
defined trait Bar
defined object Bar
scala> implicitly[Foo[String]]
<console>:14: error: Custom ambiguous message
implicitly[Foo[String]]
^
scala> implicitly[Bar[String]]
<console>:14: error: ambiguous implicit values:
both method a in object Bar of type => Bar[String]
and method b in object Bar of type => Bar[String]
match expected type Bar[String]
implicitly[Bar[String]]
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment