sbt 编译时警告:类型模式 List[String] 中的非变量类型参数 String [英] sbt compile time warning: non-variable type argument String in type pattern List[String]
本文介绍了sbt 编译时警告:类型模式 List[String] 中的非变量类型参数 String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 sbt 显示警告信息
My sbt is showing a warning message
non-variable type argument String in type pattern List[String] (the underlying of List[String]) is unchecked since it is eliminated by erasure
我尝试了链接中给出的答案(第一个解决方案)
I tried the answer given in the link (first solution)
scala 中的擦除消除:非可变类型参数未检查,因为它被擦除消除
这是我的代码
case class ListStrings(values:scala.List[String]) { }
def matchValue(value: Any) = {
value match {
case ListStrings(xs) =>
val userList = xs
case _ => log.error("unknown value")
}
}
val list: List[String] = List("6","7","8")
matchValue(list)
我得到未知值"作为输出,为什么它不匹配?我在这里缺少什么?
I am getting "unknown value" as an output why its not matching ? what i am missing here?
推荐答案
因为你通过了 list
而不是 ListStrings(list)
Because you passed list
instead of ListStrings(list)
这篇关于sbt 编译时警告:类型模式 List[String] 中的非变量类型参数 String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文