Created
December 9, 2010 17:47
-
-
Save maxaf/735043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait X | |
case class A(i: Int) extends X | |
case class B(i: Int) extends X | |
implicit def int2a(i: Int): A = A(i) | |
implicit def int2b(i: Int): B = B(i) | |
implicit def int2x(i: Int)(implicit multiplier: Int): X = | |
if (System.currentTimeMillis % 100 == 0) A(i * multiplier) else B(i * multiplier) | |
val a: A = 1 | |
val b: B = 2 | |
val x: X = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ambig.scala:13: error: type mismatch; | |
found : Int(3) | |
required: this.X | |
Note that implicit conversions are not applicable because they are ambiguous: | |
both method int2x of type (i: Int)(implicit multiplier: Int)this.X | |
and method int2b of type (i: Int)this.B | |
are possible conversion functions from Int(3) to this.X | |
val x: X = 3 | |
^ | |
one error found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment