Type inferred to Nothing with default parameter type class instance

I'm trying out reactivemongo and struck type inference problems in Idea. Type inference works in external build but not in Idea. Calling this method:

  def collection[C <: Collection](name: String, failoverStrategy: FailoverStrategy = failoverStrategy)(implicit producer: CollectionProducer[C] = collections.default.BSONCollectionProducer): C = {
    producer.apply(this, name, failoverStrategy)
  }

without supplying the producer argument should yield C = BSONCollection since BSONCollectionProducer extends CollectionProducer[BSONCollection]. But the return type when overiding in IDEA is Nothing and everything turns red.



I try to find it on the blog, but there is little mention of the homebrewed "presentation compiler" lately. Reading this article http://blog.jetbrains.com/scala/2012/12/28/a-new-way-to-compile/ you can almost get the feeling that scalac is the only one nowadays: "We need to compile source code to bytecode (and to search for all kind of errors along the way). This task is always performed by Scalac" (I might get the feeling that the "always" includes the "and"?)

This (2011-03-11) is still true, right:

"Scala plugin doesn’t rely on compiler to analyze code. We’re implementing our own model of the language, and sometimes it’s challenging, especially when it comes to Scala’s type system and type inference (to size up the problem, you may try to formally “infer” a type of “foo”.map(_ + 1) expression by hand)."

That is, SBT+scala always does the compilation to bytecode and some of the error reporting, but there is still a homebrewed "compiler" that does error reporting too and code completion? Idea is still not using the presentation compiler from the Scala project, right?

Thanks,
Viktor

3 comments
Comment actions Permalink

Yes, IDEA doesn't rely on presentation compiler.
For your problem please create a ticket with fully reproducible example (it requires sample SBT/Maven etc project, or simple code snippet, if it doesn't require any dependencies) here: http://youtrack.jetbrains.com/issues/SCL

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

I actually tried that, but I haven't found any "create" button on the youtrack thing. There is something messed up with my permissions on your issue tracker. I can't even view http://youtrack.jetbrains.com/user.

Here you have something minified though:

https://github.com/hedefalk/idea-type-inference-nothing/
https://github.com/hedefalk/idea-type-inference-nothing/blob/master/src/main/scala/Foo.scala

Thanks,
Viktor

0
Comment actions Permalink

We have such issues and we will fix it:
http://youtrack.jetbrains.com/issue/SCL-2507 and
http://youtrack.jetbrains.com/issue/SCL-2508
It's about adding type parameters inference from default values, which is not implemented yet.

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.