Created
June 10, 2014 03:08
-
-
Save jedws/aa4e48371a745473e271 to your computer and use it in GitHub Desktop.
Pattern matching on a case object is affected by whether the outer trait is parameterised or not
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
trait A { | |
sealed trait Foo | |
case object Bar extends Foo | |
case class Baz() extends Foo | |
def isBar(f: Foo) = f match { | |
case Bar => true | |
case Baz() => false | |
} | |
} | |
trait B[V] { | |
sealed trait Foo | |
case object Bar extends Foo | |
case class Baz() extends Foo | |
def isBar(f: Foo) = f match { | |
case Bar => true | |
case Baz() => false | |
} | |
} | |
// [warn] /…/test/src/main/scala/scalacbug.scala:17: match may not be exhaustive. | |
// [warn] It would fail on the following input: Bar | |
// [warn] def isBar(f: Foo) = f match { | |
// [warn] ^ | |
// [warn] one warning found |
Weird.
Thanks for the issue reference, I couldn't find it. And I'm glad this is now fixed :-).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://issues.scala-lang.org/browse/SI-8546