scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

curried constructors could be implicitly eta-expanded #8729

Open scabug opened 10 years ago

scabug commented 10 years ago

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>

This inconsistency seems unwarranted.

scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8729?orig=1 Reporter: Dan Rosen (mergeconflict)