本文介绍了scala 开发人员如何处理带有 shapeless 的 scala 代码中不正确的 IDE(Idea) 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个带有具体示例的一般问题.

人们如何进入 scala 并将其用于大型项目,以解决工具/IDE 的不可靠性问题?您是否只接受整个源代码中的红色标记?

我遇到了另一个 Scala 代码库,其中工作代码被idea 标记为红色无法解析符号代表.

我开始了一个游乐场项目来探索代码库中的一个库 - shapeless(据我所知,它是 Scala 社区中备受推崇的库).

我从官方无形指南的第一页写了非常基本的代码.

包示例进口无形._对象你好扩展应用{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())}案例类员工(名称:字符串,isOld:布尔值)case class IceCream (name: String, isInCone: Boolean)

gen(0)gen(1) 被标记为 在 hlist.At[String :: Boolean :: HNil 处没有找到参数的隐式,Nat#N]

代码有效.

我还记得由 Akka HTTP 引起的错误但不是真正的错误.

解决方案

IntelliJ 支持依赖于 shapeless 等宏的库似乎存在根本性的困难

如何处理错误的错误?

所以,事实是你必须记住,有时没有勺子错误.为了帮助我们修复突出显示的故障,您可以将其报告给YouTrack 照常或在错误的高亮处按 Alt+Enter:

This is a general question with a specific example.

How do people getting into scala and using it for big projects handle unreliability of tools/IDE? Do you just accept red markings all over your source code?

I encounter yet another scala codebase where working code is flagged red by idea Cannot resolve symbol Repr.

I start a playground project to explore one of libraries in the codebase - shapeless (as I understand it a highly regarded library in scala community).

I write extremely basic code from the first page of official shapeless guide.

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) and gen(1) are flagged with No implicits found for parameter at hlist.At[String :: Boolean :: HNil, Nat#N]

The code works.

I also remember errors-but-not-real-errors being caused by Akka HTTP.

解决方案

There seems to be a fundamental difficulty in IntelliJ supporting libraries relying on macros such as shapeless

@niktrop

@joroKr21

@olafurpg


You could try reporting highlighting errors as a bug at

https://youtrack.jetbrains.com/issues/SCL

Here is an example you could use as a template

https://youtrack.jetbrains.com/issue/SCL-16091

Select the affected subsystem as Error Highlighting

This feature is called Type-aware highlighting and can be disabled by clicking on the little T icon in bottom right corner

这篇关于scala 开发人员如何处理带有 shapeless 的 scala 代码中不正确的 IDE(Idea) 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:40