False errors when using cat library in IntelliJ

I use the cats Scala library, and the IntelliJ IDE seems to be struggling with implicits:

Here is a simple example:

import cats.std.all._ import cats.Traverse.ops._ def useSequence[A](ls : List[Option[A]]) : Option[List[A]] = { ls.sequence } 

In IntelliJ, this code is highlighted in red. But I can build just fine using the Make Project or command line.

Now the error is:

An expression of type Nothing [List [Nothing]] does not match the expected type Option [List [A]]

In other cases, the error looks something like this:

the sequence of values ​​is not a member of List [Option [A]]

Is this a bug in IntelliJ or am I missing any configuration?

I am using IntelliJ 15.0.2 with version 2.0.4 of the Scala plugin.

+8
scala intellij-idea implicits scala-cats
source share
1 answer

This is an open problem in the IntelliJ / Scala plugin ( SCL-10259 - false error (good code red): sequence from cats ) opens from May 13, 2016.

As @Noah's comments above, the workaround for now is to help IntelliJ exit by providing container types and contained types that the sequence applies to, i.e. (updated for cats 1.0):

 import cats.instances.all._ import cats.Traverse.ops._ def useSequence[A](ls : List[Option[A]]) : Option[List[A]] = ls.sequence[Option, A] 
0
source share

All Articles