1

This compiles just fine with sbt:

  val a: ValidatedNel[String, Int] = 10.valid

  a |@| a

But in IntelliJ, it shows up as an error:

IntelliJ1

This makes functional error handling with Cats very inconvenient. All my "IDE-compile-time" typesafety is gone; and it makes the code really painful to work with since intellij will constantly tell you that you've "messed up" (even though the code is perfectly fine).

Is there another way of writing this that doesn't make IntelliJ flip out? For instance, if there was some alias to the |@| that intellij understood?

Also, does anyone know why IntelliJ doesn't understand the syntax - it perfectly understands the |+| syntax:

Intellij2

elixenide
  • 44,308
  • 16
  • 74
  • 100
kornfridge
  • 5,102
  • 6
  • 28
  • 40
  • unfortunately this is a known problem of IntelliJ. Here's a few more references on SO. http://stackoverflow.com/questions/36679973/controlling-false-intellij-code-editor-error-in-scala-plugin http://stackoverflow.com/questions/21773436/scalaz-code-highlighted-with-red-in-intellij-idea-12-and-13 – Gabriele Petronella Sep 04 '16 at 22:45
  • 1
    The first link suggests you turn off all the type-awareness in Intellij which just instantly defeats the purpose of using an IDE. The second just acknowledges that intellij-scala has problems. Neither really helps :( I need a workaround until they (bother to) fix it. – kornfridge Sep 04 '16 at 22:56
  • 1
    yep, those were references to confirm the problem with intellij, not a solution (I would've posted an answer otherwise). I'm not aware of any workaround, sorry. – Gabriele Petronella Sep 04 '16 at 22:58
  • 2
    Since we're linking things, here's a youtrack ticket for the bug: https://youtrack.jetbrains.com/issue/SCL-10237 – kornfridge Sep 04 '16 at 23:03
  • anyway, a possible reason of *why* `|@|` causes problems and `|+|` does not is that the former is overloaded on several variations of `CartesianBuilder` which are generated by a boilerplate. Probably IntelliJ can't resolve the correct overload. – Gabriele Petronella Sep 04 '16 at 23:14
  • see https://github.com/typelevel/cats/blob/a0aa6e0d307c80652a5805bcf0a6898d77855480/project/Boilerplate.scala#L98-L153 – Gabriele Petronella Sep 04 '16 at 23:15

1 Answers1

1

This problem is resolved in the latest IntelliJ-Scala releases: https://youtrack.jetbrains.com/issue/SCL-10237

Justin Kaeser
  • 5,868
  • 27
  • 46