Starting on two new things at the same time: IntelliJ + Scala (+ Play).
I am having some strange issue on IntelliJ reporting errors on the editor if I import play.api._ on the same class. Project is a new project created with IntelliJ scala+play 2.4 template.
Example file ImportError.scala in app/controllers/subpackage:
package controllers.subpackage
import play.api._
import controllers.ClassToImport
class ImportError {
val instance = new ClassToImport()
}
IntelliJ editor is givin me error on line "import controllers.ClassToImport": "Cannot resolve symbol ClassToImport"
If I select 'Recompile ImportError.scala", the console gives no compile errors.
If I change the class by removing the play.api import like this:
package controllers.subpackage
import controllers.ClassToImport
class ImportError {
val instance = new ClassToImport()
}
Then IntelliJ no longer gives me errors on the editor.
Also here are other observations of the situation:
- If I cut-paste the latter import before the play import, IntelliJ will change my imports to: 'import controllers.ClassToImport' and 'import play.api.{controllers, _}', so here must be some clue. Why does it think I want controllers from play api?
- If I change the order of the two imports then both editor and compile result are happy.
- If I change the play import to "import play.api.controllers" then editor is happy but compile result is "object controllers is not a member of package play.api". I do not understand this at all, as to my understanding (as shown by the error) there does not exist play.api.controllers, so why is IntelliJ editor accepting it?
The above example is a isolated example of the problem I am facing in a real project with importing play.api._ with IntelliJ. Should be easily reproducable with the latest IntelliJ IDEA community 2016.2.4.