Created
November 25, 2015 06:27
-
-
Save binshuohu/2a0e7885f724c3466441 to your computer and use it in GitHub Desktop.
test whether implicit evidence needs both covariance and contravariance
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
object Crap extends App { | |
sealed abstract class <=<[From, +To] extends (From => To) { | |
} | |
implicit def conforms[A]: <=<[A, A] = new <=<[A, A] { | |
def apply(from: A): A = ??? | |
} | |
class A[T] { | |
def foo[U](u: U)(implicit ev: <=<[U, T]) = () | |
def bar[U](u: U)(implicit ev: <=<[T, U]) = () | |
} | |
val a = new A[AnyVal] | |
val x: Any = 12 | |
a.foo(12) | |
a.bar(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment