Lack of warning about an inexhaustible match

Why the following -unchecked not displayed on the next -unchecked :

 object Order { sealed trait EntryOption case object EmptyEntry extends EntryOption trait Entry extends EntryOption def isEmpty(a: EntryOption): Boolean = a match { case EmptyEntry => true // case _: Entry => false } } 

It seems that I had exactly the same problem before in the days of Scala 2.8.0 without a sufficient answer.


EDIT

@Jed It doesn't matter to me that a warning is issued only for a non-abstract Entry class. Consider the following situation:

 trait Order { sealed trait EntryOption case object EmptyEntry extends EntryOption abstract sealed class Entry extends EntryOption def isEmpty(a: EntryOption): Boolean = a match { case EmptyEntry => true // case _: Entry => false } } trait OrderImpl extends Order { final class EntryImpl extends Entry } 

The only way to make a warning is to have a specific Entry class in Order !

+6
source share
2 answers

He complains about the chest:

 scala> object Order { | sealed trait EntryOption | case object EmptyEntry extends EntryOption | trait Entry extends EntryOption | | def isEmpty( a: EntryOption ) : Boolean = a match { | case EmptyEntry => true | // case _: Entry => false | } | } <console>:18: warning: match is not exhaustive! missing combination Entry def isEmpty( a: EntryOption ) : Boolean = a match { ^ defined module Order 
+3
source

An entry is a sign, not a case class.

+2
source

Source: https://habr.com/ru/post/902514/


All Articles