editor doesn't recognize implicits i.e. net.codingwell.scalaguice.InjectorExtensions._

This used to occur in older intellij versions but in latest 2017.2 it occurs almost all the time.

I've code that uses https://github.com/codingwell/scala-guice

import net.codingwell.scalaguice.InjectorExtensions._

And then

val x=injector.inject[XClass]

"inject" is an implicit defined in the InjectorExtensions but it is not recognised by the editor. Effectively it disables autocomplete and also organizing imports incorrectly removes the import.

I tried restarting ,"invalidate caches / restart" (this used to work sometimes in older versions) etc without any luck. Sometimes if I move the import statement around, it starts to work but only for a little while.

Any ideas what might be going wrong? This mainly occurs in scala-test cases I think , where probably there are a lot of implicits.

object InjectorExtensions {

implicit class ScalaInjector(i: Injector) {
def instance[T: Manifest] = i.getInstance(typeLiteral[T].toKey)
def instance[T: Manifest](ann: Annotation) = i.getInstance(typeLiteral[T].annotatedWith(ann))
def instance[T: Manifest, Ann <: Annotation : Manifest] = i.getInstance(typeLiteral[T].annotatedWith[Ann])
....
}
}

 

 

 

0
2 comments

Actually just found that the "injector" type was not correctly recognised by the editor:

val injector = Guice.createInjector(modules: _*)

If I manually add the type, it works:
val injector : Injector = Guice.createInjector(modules: _*)

That's weird because the signature of the method is pretty straight forward:

public static Injector createInjector(Module... modules)
0

This issue needs an investigation. I've created https://youtrack.jetbrains.com/issue/SCL-12432 for this.

0

Please sign in to leave a comment.