这是一个带有具体示例的一般问题。
人们如何进入 Scala 并将其用于大型项目处理工具/IDE 的不可靠性?您是否只接受整个源代码中的红色标记?
我遇到了另一个 Scala 代码库,其中工作代码被想法标记为红色 Cannot resolve symbol Repr
.
我开始了一个游乐场项目来探索代码库中的一个库 - shapeless(据我所知,它是 Scala 社区中备受推崇的库)。
我从官方无形指南的第一页编写了非常基本的代码。
package example
import shapeless._
object Hello extends App {
val genericEmployee = Generic[Employee].to(Employee("Dave", isOld = true))
val genericIceCream = Generic[IceCream].to(IceCream("yellow", isInCone = false))
def genericCsv (gen: String :: Boolean :: HNil) :List[String] = List(gen(0), gen(1).toString())
println(genericCsv(genericIceCream).toString())
}
case class Employee (name: String, isOld: Boolean)
case class IceCream (name: String, isInCone: Boolean)
gen(0)
和 gen(1)
被标记为 No implicits found for parameter at hlist.At[String :: Boolean :: HNil, Nat#N]
该代码有效。
我还记得由 Akka HTTP 引起的错误但不是真正的错误。
最佳答案
IntelliJ 支持依赖于宏(例如 shapeless)的库似乎存在根本性的困难
@niktrop
Shapeless is heavily using macros. We have no way to support them generically.
@joroKr21
there is a fundamental barrier for whitebox macros. You have to run a complete typecheck and expand them just to see what type they return and this is not feasible to do on every keystroke. Blackbox macros on the other hand shouldn't pose such problems.
@olafurpg
scala-compiler and intellij-scala are different typecheckers, scala-reflect macros are currently implemented against scala-compiler APIs which makes them difficult to support in alternative scala compilers.
您可以尝试将突出显示错误报告为 bug在
https://youtrack.jetbrains.com/issues/SCL
这是您可以用作模板的示例
https://youtrack.jetbrains.com/issue/SCL-16091
选择受影响的子系统为
Error Highlighting
此功能称为 Type-aware highlighting并且可以通过单击小
T
来禁用右下角的图标How to deal with false errors?
So, the truth is you have to remember that sometimes there’s no spoon error. To help us to fix a highlighting glitch you may report it to YouTrack as usual or by pressing Alt+Enter on wrong highlight:
关于scala - scala 开发人员如何处理带有 shapeless 的 scala 代码中不正确的 IDE(Idea) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62285485/