by shigemk2

当面は技術的なことしか書かない

match is not exhaustive 回避

普通に非推奨でしょう。。。

パターンマッチのところに@uncheckedをつけると、match is not exhaustiveのwarningを回避できる。

object Test extends App {
  // This would normally warn "match is not exhaustive"
  // because `None` is not covered.
  def f(x: Option[String]) = (x: @unchecked) match { case Some(y) => y }
  // This would normally warn "type pattern is unchecked"
  // but here will blindly cast the head element to String.
  def g(xs: Any) = xs match { case x: List[String @unchecked] => x.head }
}

stackoverflow.com

@uncheckedのアノテーションについて。

www.scala-lang.org