Richard Pianka Richard Pianka - 1 year ago 83
Scala Question

Slick 2.0 and IntelliJ, highlighting errors

I'm in the process of migrating to Slick 2.0.0-RC1 (from 1.x), and I'm having trouble getting IntelliJ to recognize the lifted embedding implicits around the

statements. However, everything does compile, in both IntelliJ and sbt (read: play). I started by leveraging the new code generation feature, and just now I grabbed snippets from slick-examples verbatim — both produce the same behavior.

Using the first example of lifted embedding ( the following two things occur:

  • The line:

    def supplier = foreignKey("SUP_FK", supID, suppliers)(

    Produces an error on
    Type mismatch, expected: TableQuery[NotInferredTT], actual: ((Tag) => FirstExample.Suppliers) => TableQuery[FirstExample.Suppliers]

  • The
    vals (e.g., coffees) don't have any of the lifted collection-like operations on them (e.g., filter, map, take, etc.).

Weirdly enough, using for-comprehensions doesn't produce any errors, however nothing has the right type information (ends up as an

I'm positive that I've got the
import (it doesn't compile elsewhere without it). I've cleared all my caches, rerun my gen-idea, done full rebuilds, etc. with no progress. I'm running IntelliJ 12.1.6 Ultimate with the Scala 0.22.302 plugin. My own project uses SQLServer, but I tried the example with H2 and experienced the same thing.

Can someone point me in the right direction?

Answer Source

I found a hack to get around this, but I'm really looking for something more robust. If I override SourceCodeGenerator, and then override the TableDef inside that, and then override the TableValueDef inside that, I can override the def code inside that to this:

override def code = s"lazy val $name = TableQuery[${}](tag => new ${}(tag))"

...and then I don't have problems with the macro not evaluating. It goes without saying that this isn't an ideal solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download