Reports type checks and type casts in a series of if-else statements and replaces them with pattern matching.

Example:


  val value = 0
  if (value.isInstanceOf[Int]) {
    val x = value.asInstanceOf[Int] + 1
    val y = value.asInstanceOf[Int] + 2
  } else if (value.isInstanceOf[Long]) {
    val x = value.asInstanceOf[Long]
    println(x)
  }

After the quick-fix is applied:


  val value = 0
  value match {
    case i: Int =>
      val x = i + 1
      val y = i + 2
    case x: Long =>
      println(x)
    case _ =>
  }