All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wartremover.warts.Option2Iterable.scala Maven / Gradle / Ivy

There is a newer version: 3.2.4
Show newest version
package org.wartremover
package warts

object Option2Iterable extends WartTraverser {
  def apply(u: WartUniverse): u.Traverser = {
    import u.universe._

    val scala = TypeName("scala")
    val option = TermName("Option")
    val option2Iterable = TermName("option2Iterable")

    new u.Traverser {
      override def traverse(tree: Tree): Unit = {
        tree match {
          // Ignore trees marked by SuppressWarnings
          case t if hasWartAnnotation(u)(t) =>
          case Select(Select(This(pkg), obj), method) if pkg == scala && obj == option && method == option2Iterable =>
            error(u)(tree.pos, "Implicit conversion from Option to Iterable is disabled - use Option#toList instead")
          case _ =>
            super.traverse(tree)
        }
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy