Skip to content

Instantly share code, notes, and snippets.

@jedws
Created June 10, 2014 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedws/aa4e48371a745473e271 to your computer and use it in GitHub Desktop.
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
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
@jedws
Copy link
Author

jedws commented Jun 10, 2014

@etorreborre
Copy link

Weird.

@etorreborre
Copy link

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