I want to leverage the warning that Scala issues when a matching is missing ("not exhaustive") - so that I don't forget one (I have dozens). The following simplified example shows my attempt:
sealed case class MESSAGE() class SUCCESS_MESSAGE extends MESSAGE class FAILURE_MESSAGE extends MESSAGE def log(str: String, msgType: MESSAGE) { msgType match { case t:SUCCESS_MESSAGE => println("FAILURE: " + str) case t:FAILURE_MESSAGE => println("SUCCESS: " + str) } } The problem is that it says "match is not exhaustive!" although all possible combinations are listed. If I'd put the "case _ =>" in there, the whole point of the warning is invalidated for me because I could add
class INFO_MESSAGE extends MESSAGE and no warning would be issued.
Is there a solution?