Created
July 25, 2013 23:17
-
-
Save andresilva/6084682 to your computer and use it in GitHub Desktop.
Low priority implicits issue
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
def test(m: Magnet): Int = m.i | |
class Magnet(val i: Int) | |
object Magnet extends LowerPriorityMagnet { | |
implicit def fromUnitWithInt(u: Unit)(implicit i: Int) = new Magnet(i) | |
} | |
abstract class LowerPriorityMagnet { | |
implicit def fromUnitWithString(u: Unit)(implicit s: String) = new Magnet(s.toInt) | |
} | |
implicit val ev = 3 | |
test() == 3 // true | |
implicit val ev = "3" | |
test() == 3 | |
// <console>:32: error: not enough arguments for method test: (m: Magnet)Int. | |
// Unspecified value parameter m. | |
// test() | |
// ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment