【问题标题】:IntelliJ does not hit Breakpoint but code is executed (console shows println)IntelliJ 未命中断点但代码已执行(控制台显示 println)
【发布时间】:2019-10-09 20:04:00
【问题描述】:

为什么 IntelliJ 无法调试线路 println(s"foo: $nr") 在下面的代码中? 我做错了吗?

当我删除/评论该行时 val neverUsed = () => f 调试工作正常,执行在调试器窗口中按预期停止。

object Test {

  def wrap(f: Int => String): Int => String = {

    val foo = (nr: Int) => {

      println(s"foo: $nr") // <--- Breakpoint added here!

      // This declaration seems to prevent debugging.
      // when removed or commented out debugging works as expected.
      val neverUsed = () => f

      s"FOO $nr"
    }

    nr: Int => foo(nr)
  }

  def main(args: Array[String]) {
    println(wrap(_.toString)(123))
  }
}

【问题讨论】:

  • 我尝试了你的代码,它成功地停在了断点处,无论你指向的行有还是没有。尝试通过 > File | Invalidate Caches/Restart 使缓存无效。一个愚蠢的问题:您确定您处于调试模式而不是正常运行模式吗?

标签: scala debugging intellij-idea functional-programming breakpoints


【解决方案1】:

dionysis-nt 是对的。这是我本地 IntelliJ 安装的问题。所以上面的代码没有错。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-28
    • 1970-01-01
    • 2013-10-05
    • 2014-08-28
    • 2022-12-18
    • 2018-09-07
    • 1970-01-01
    • 2016-10-27
    相关资源
    最近更新 更多