Replacing case class inheritance with extractors preserving exhaustiveness checks in Scala

后端 未结 3 1363
说谎
说谎 2021-01-04 23:39

I have a simple class hierarchy that represents a graph-like structure with several distinct types of vertexes implemented using case classes:

sealed trait N         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 00:08

    The citation from scala-lang.org:

    If the selector of a pattern match is an instance of a sealed class, the compilation of pattern matching can emit warnings which diagnose that a given set of patterns is not exhaustive, i.e. that there is a possibility of a MatchErrorbeing raised at run-time.

提交回复
热议问题