How to fix compiler warning on scala.xml.Elem -
the following code generates compilation warning : a repeated case parameter or extracted sequence should matched sequence wildcard (_*)
import scala.xml.elem def matchelem(e: elem) = e match { case <source/> => "match!" } how fix ?
you can use scalac -xlint:-stars-align,_ suppress warning, this issue.
your function looks -xprint:typer:
def matchelem(e: scala.xml.elem): string = e match { case scala.xml.elem.unapplyseq(<unapply-selector>) <unapply> (_, "source", _, _) => "match!" } to answer question:
$ scala -xlint welcome scala version 2.11.6 (java hotspot(tm) 64-bit server vm, java 1.8.0_45). type in expressions have them evaluated. type :help more information. scala> import xml._ import xml._ scala> def matchelem(e: elem) = e match { case elem(_, "source", _, _, _*) => "match!" } matchelem: (e: scala.xml.elem)string or embed sequence wildcard in pattern:
scala> <a/> match { case <a/> => } <console>:8: warning: repeated case parameter or extracted sequence should matched sequence wildcard (_*). <a/> match { case <a/> => } ^ scala> <a/> match { case <a>{ ns @ _* }</a> if ns.isempty => }
Comments
Post a Comment