8

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.

John H
  • 83
  • 3

1 Answers1

6

There seems to be a fundamental difficulty in IntelliJ supporting libraries relying on macros such as 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.


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

enter image description here

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:

Mario Galic
  • 47,285
  • 6
  • 56
  • 98