scala.MatchError:?>:Nothing&lt ;: Any(类scala.tools.nsc.symtab.Types $ BoundedWildcardType)

时间:2012-05-31 20:39:50

标签: scala

使用SBT 0.11.3和Scala 2.9.1编译项目时没有错误。使用'sbt run'运行没有问题。然而,'sbt test'给了我这个:

$ sbt test
[info] Loading global plugins from /home/mslinn/.sbt/plugins
[info] Loading project definition from /home/mslinn/work/domain-bus/project
[info] Set current project to domainbus (in build file:/home/mslinn/work/domain-bus/)
[error] {file:/home/mslinn/work/domain-bus/}domainbus/test:compile: scala.MatchError: ?>: Nothing <: Any (of class scala.tools.nsc.symtab.Types$BoundedWildcardType)
[error] Total time: 7 s, completed May 31, 2012 1:20:46 PM

没有源代码引用,只是一个错误,这对我来说毫无意义。我用Scala 2.9.1-1得到了相同的结果。 IDEA疯狂地试图用2.9.1和2.9.1-1进行编译。这里有额外的信息,也许这将提供一个线索:

Information:Compilation completed with 68 errors and 0 warnings
Information:68 errors
Information:0 warnings
Error: scala.MatchError: ?>: Nothing <: Any (of class scala.tools.nsc.symtab.Types$BoundedWildcardType)
Error:at scala.tools.nsc.typechecker.Variances$class.varianceInType(Variances.scala:67)
Error:at scala.tools.nsc.Global$analyzer$.varianceInType(Global.scala:351)
Error:at scala.tools.nsc.typechecker.Variances$$anonfun$varianceInArgs$2.apply(Variances.scala:48)
Error:at scala.tools.nsc.typechecker.Variances$$anonfun$varianceInArgs$2.apply(Variances.scala:47)
Error:at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
Error:at scala.collection.immutable.List.foreach(List.scala:45)
Error:at scala.tools.nsc.typechecker.Variances$class.varianceInArgs(Variances.scala:47)
Error:at scala.tools.nsc.Global$analyzer$.varianceInArgs(Global.scala:351)
Error:at scala.tools.nsc.typechecker.Variances$class.varianceInType(Variances.scala:74)
Error:at scala.tools.nsc.typechecker.Variances$$anonfun$varianceInTypes$1.apply(Variances.scala:40)
Error:at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
Error:at scala.collection.immutable.List.foldLeft(List.scala:45)
Error:at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:137)
Error:at scala.collection.immutable.List.$div$colon(List.scala:45)
Error:at scala.tools.nsc.typechecker.Variances$class.varianceInTypes(Variances.scala:40)
Error:at scala.tools.nsc.Global$analyzer$.varianceInTypes(Global.scala:351)
Error:at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$protoTypeArgs$1.apply(Infer.scala:573)
Error:at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$protoTypeArgs$1.apply(Infer.scala:572)
Error:at scala.Tuple2$Zipped$$anonfun$map$1.apply(Tuple2.scala:65)
Error:at scala.Tuple2$Zipped$$anonfun$map$1.apply(Tuple2.scala:63)
Error:at scala.Tuple2$Zipped.map(Tuple2.scala:63)
Error:at scala.tools.nsc.typechecker.Infer$Inferencer.protoTypeArgs(Infer.scala:572)
Error:at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:2467)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:3371)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4104)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4271)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4344)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedIf$1(Typers.scala:3158)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3987)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:1957)
Error:at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedCases$1.apply(Typers.scala:1975)
Error:at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedCases$1.apply(Typers.scala:1974)
Error:at scala.collection.immutable.List.loop$1(List.scala:117)
Error:at scala.collection.immutable.List.mapConserve(List.scala:133)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:1974)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4003)
Error:at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4428)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1760)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3919)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2100)
Error:at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2184)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2184)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1512)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1320)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3913)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3906)
Error:at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4331)
Error:at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:94)
Error:at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
Error:at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:86)
Error:at scala.collection.Iterator$class.foreach(Iterator.scala:660)
Error:at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:316)
Error:at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:86)
Error:at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
Error:at scala.tools.nsc.Global$Run.compile(Global.scala:1038)
Error:at scala.tools.nsc.Main$.process(Main.scala:106)
Error:at scala.tools.nsc.Main$.main(Main.scala:123)
Error:at scala.tools.nsc.Main.main(Main.scala)
Error:at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:at java.lang.reflect.Method.invoke(Method.java:597)
Error:at org.jetbrains.plugins.scala.compiler.rt.ClassRunner.main(ClassRunner.java:46)
Error:
Error:Exception in thread "main" java.lang.reflect.InvocationTargetException
Error:Caused by: scala.MatchError: ?>: Nothing <: Any (of class scala.tools.nsc.symtab.Types$BoundedWildcardType)
Error:... 5 more

建议?

麦克

1 个答案:

答案 0 :(得分:3)

好的,这是问题的原因,以防其他人点击它。我有一个使用此签名在单元测试中定义的方法,它炸毁了Scala编译器:

def sendMsgs(tickEventOptions: Option[Seq[_]], broadcast: Boolean): Unit

无类型的Seq是问题所在。以这种方式定义允许编译器不会死:

def sendMsgs(tickEventOptions: Option[Seq[String]], broadcast: Boolean): Unit

麦克