Last active
January 22, 2017 19:23
-
-
Save mielientiev/1873b2aea8f6f2bff81e13b597a7849c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 TestCo { | |
type CoVariant[+T, _ <: Exception] | |
def unwrap[T](value: => CoVariant[T, _ <: Exception]): T | |
} | |
// works fine, since Option is covariant | |
class TestCoImpl extends TestCo { | |
type CoVariant[+T, _ <: Exception] = Option[T] | |
def unwrap[T](value: => CoVariant[T, _ <: Exception]): T = value.get | |
} | |
//covariant type CoVariant occurs in contravariant position in type => TestCoFailed.this.CoVariant[T] of value value | |
// def unwrap[T](value: => CoVariant[T]): T = value | |
class TestCoFailed extends TestCo { | |
type CoVariant[+T, _ <: Exception] = T | |
def unwrap[T](value: => CoVariant[T, _ <: Exception]): T = value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment