为什么此代码会抛出异常?在定义我自己的toInt方法时scala中的异常
val x = new { def toInt(n: Int) = n*2 }
x.toInt(2)
scala.tools.nsc.symtab.Types$TypeError: too many arguments for method toInteger: (x$1: java.lang.Object)java.lang.Integer
at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:298)
at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:207)
at scala.tools.nsc.typechecker.Infer$Inferencer.errorTree(Infer.scala:211)
at scala.tools.nsc.typechecker.Typers$Typer.tryNamesDefaults$1(Typers.scala:2350)
...
我使用Scala的2.9.1.final
由于这是一个编译器错误,我建议通过在[Scala的问题跟踪器](https://issues.scala-lang.org/secure/Dashboard.jspa)中提交错误报告来更好地制作Scala。 – leedm777 2012-03-15 18:30:09
不会在2.10中继上崩溃。 – soc 2012-03-16 00:22:59