The language spec (sec. 6.26.2) states that eta-expansion only applies to curried methods that aren't constructors; this restriction seems arbitrary. If I can write:
scala> case class Foo(a: Int)(b: Int)
defined class Foo
scala> val f: Int => Foo = Foo(3)
f: Int => Foo = <function1>
then I don't see why:
scala> val f: Int => Foo = new Foo(3)
<console>:9: error: missing arguments for constructor Foo in class Foo
should be forbidden. If Foo isn't a case class (or doesn't otherwise have a curried apply method) it's necessary to manually eta-expand:
scala> val f: Int => Foo = new Foo(3)(_)
f: Int => Foo = <function1>
The language spec (sec. 6.26.2) states that eta-expansion only applies to curried methods that aren't constructors; this restriction seems arbitrary. If I can write:
then I don't see why:
should be forbidden. If
Foo
isn't a case class (or doesn't otherwise have a curriedapply
method) it's necessary to manually eta-expand:This inconsistency seems unwarranted.