Search code examples
scalaintellij-ideaintellij-scala

'wrong top statement declaration' when using slick in IntelliJ


I'm currently porting a project from scala 2.9 to 2.10, therefore I have to use slick instead of scalaquery. I'm using slick 2.1.0 for now since it supports MS Access.

According to this tutorial and the upgrade guide I changed Robs from object to class and added the val robs:

Error defining val robs

Why do I get the error message Wrong top statement declaration and how do I get rid of it?

EDIT: I'm new to scala... According to this question it seems like I can't put a val outside of methods or classes, right? The code above is directly in a packge. But what is the right approach for slick then? Should I move the code in some class or trait?


Solution

  • According to this I changed

    val robs = TableQuery[Robs]

    to

    object robs extends TableQuery(new Robs(_)) {}.

    No warnings or errors anymore. :)