There seems to be an issue with the autocompletion in the presentation compiler. It’s a bit of an edge case, I guess that’s why it wasn’t discovered yet: Autocompletion fails when using dependent types AND omitting the (empty) first parameter block. You can reproduce it in the repl as follows:
object Test1 {
trait Conv[In] {
type Out
def apply(in: In): Out
}
object Conv {
type Aux[In, Out0] = Conv[In] { type Out = Out0 }
implicit val int2String = new Conv[Int] {
type Out = String
override def apply(i: Int) = i.toString
}
}
def withParens[Out]()(implicit conv: Conv.Aux[Int, Out]): Out = "5".asInstanceOf[Out]
def withoutParens[Out](implicit conv: Conv.Aux[Int, Out]): Out = "5".asInstanceOf[Out]
}
Then type Test1.withParens().<TAB>
- it does find autocompletions for String. However, if you try Test1.withoutParens.<TAB>
it does not. As a workaround, when saving intermediate result, it works:
val a = Test1.withoutParens; a.<TAB>
Without dependent types, autocompletion works fine in both cases:
object Test2 {
trait A
implicit val a: A = ???
def withParens()(implicit a: A): String = "something"
def withoutParens(implicit a: A): String = "something"
}
The best solution would be to fix this in the presentation compiler, but I didn’t manage to pin down the problem there. Instead, as a workaround, I patched the repl autocompletion - if it doesn’t find any autocompletions, it interprets the code up until that point and then tries again. Here’s a mini repo that’s using the presentation compiler and the patched autocompletion:
If you use PresentationCompilerCompleter
instead of MyPresentationCompilerCompleter
in the test, you get the old behaviour (no autocompletion).
Can someone help me fix this in the presentation compiler?
If not, should we bring an improved version of my workaround into the PresentationCompilerCompleter
?
Any other ideas?
Cheers
Michael
PS: should this move to https://github.com/scala/bug/issues ?