Intellij IDEA java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object [英] Intellij IDEA java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object

查看:42
本文介绍了Intellij IDEA java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下功能:

def removeLast(list: List[Int]): List[Int] = list match {
  case List() => List()
  case List(x) => List()
  case x :: xs => x :: removeLast(xs)
}

当我定义它并从 sbt 控制台使用它时,一切正常.但是当我在 Intellij IDEA 中创建一个工作表并尝试运行它时,会出现以下异常:

When I define it and use it from the sbt console everything works just fine. But when I create a worksheet in Intellij IDEA and try to run it then the following exception appears:

java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object;在 week5.A$A26$A$A26.removeLast(lists.sc8362409100671270508.tmp:30)在#worksheet#.#worksheet#(lists.sc8362409100671270508.tmp:33)

java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object; at week5.A$A26$A$A26.removeLast(lists.sc8362409100671270508.tmp:30) at #worksheet#.#worksheet#(lists.sc8362409100671270508.tmp:33)

另外,当我将最后一行更改为:

In addition, when I change last line to:

case x :: xs => 1 :: removeLast(xs)}

然后就可以了.

可能是什么问题?

推荐答案

我遇到了这个问题.同意 Andrzej,idea 使用自己的编译器,所以你必须以某种方式禁用它.转到Settings->Scala->Worksheet并取消选中在编译器进程中运行工作表".

I had this issue. Agree with Andrzej, idea uses its own compiler, so you have to disable it somehow. Go to Settings->Scala->Worksheet and uncheck "Run worksheet in the compiler process".

这篇关于Intellij IDEA java.lang.NoSuchMethodError: scala.collection.immutable.$colon$colon.hd$1()Ljava/lang/Object的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆