-
-
Save rightfold/758838e2a27e4c8e6fb9 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
scala> class A { | |
| case object O | |
| } | |
defined class A | |
scala> val (x, y) = (new A, new A) | |
x: A = A@543e710e | |
y: A = A@57f23557 | |
scala> x.O match { case y.O => 1; case x.O => 2 } | |
<console>:10: error: pattern type is incompatible with expected type; | |
found : y.O.type | |
required: x.O.type | |
x.O match { case y.O => 1; case x.O => 2 } | |
^ | |
scala> x.O.asInstanceOf[Any] match { case y.O => 1; case x.O => 2 } | |
res2: Int = 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment