Reputation: 1852
I want to make a helper class at the root of my core
project using play-json from typesafe, something like
package com.company
import play.api.libs.json.JsValue
object Helper {
implicit class RichJson(json: JsValue) {
def doStuff() //...
}
}
The problem is that I have somewhere else in the project a package com.company.play
package com.company.play
class Foo() { //...
}
In IntelliJ IDEA 2018.2.4 CE, the line import play.api.libs.json.JsValue
is in error with telling me "cannot resolve symbol api" and when Ctrl+Click on the play
it goes to the folder containing my Foo.scala file
If I compile the solution with sbt outside of IDEA, there is no problem.
If I put the Helper
object in a subpackage (eg com.company.common
) there is no error (which also means the dependency is correct in my build.sbt)
I don't understand why IDEA miss this, com.company.play
isn't even in the dependencies of the core
project. I already tried to invalidate cache, and it doesn't help.
Upvotes: 1
Views: 166
Reputation: 438
The problem is that Intellij gives precedence to the package play
into your project, instead of the package coming from the framework, when resolving the import of JsValue
inside com.company
scope.
If you really want to keep that name for com.company.play
, there is a simple workaround using a fully-qualified import, just prefix like this:
import _root_.play.api.libs.json.JsValue
Upvotes: 2