class Test {
def foo(x: Int) = 1
val a = foo _ // always OK
def bar = 1
val b = bar _ // Ok with -language:Scala2
}
To be consistent, I think we should also emit a warning for val a = foo _ if -language:Scala2 is given and otherwise emit an error
What would be the right way to partially apply a method?
In this example, I believe:
val a = foo
val b = () => bar
I agree we should at some point deprecate postfix _ altogether.
I think as long as we decide to support postfix _ we should leave the algorithm as is.
val a = foo _ // always OK
This eta expands with or without the postfix _. So postfix _ does not add anything here. On the other hand,
val b = bar _ // Ok with -language:Scala2
_only_ eta expands with _. That's why we forbid it currently.
I think we should consider at some point removing postfix _ altogether. Revisit the issue when there's some progress in this direction.
Most helpful comment
I agree we should at some point deprecate postfix
_altogether.