Last active
June 29, 2023 22:18
-
-
Save deanwampler/854bf3fff5097f8a0299f1994441fe43 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
// Covariance: | |
val t1s: Seq[T1] = Seq(new T1 {}) | |
val t2s: Seq[T2] = Seq(new T2 {}) | |
val t3s: Seq[T3] = Seq(new T3 {}) | |
val t123s1: Seq[T1 | T2 | T3] = t1s | |
val t123s2: Seq[T1 | T2 | T3] = t2s | |
val t123s3: Seq[T1 | T2 | T3] = t3s | |
// Contravariance? | |
val t123s: Seq[T1 | T2 | T3] = Seq(t1, t2, t3) | |
val t1s1: Seq[T1] = t123s // ERROR | |
val t2s1: Seq[T2] = t123s // ERROR | |
val t3s1: Seq[T3] = t123s // ERROR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment