4

Scala 2 does not have polymorphic function values so eta-expanding polymorphic methods gives only

scala> def f[A](a: A): A = ???
def f[A](a: A): A

scala> f _
val res0: Nothing => Nothing = $Lambda$7757/1502613782@45af2c1

However Scala 3 does have polymorphic function values so why eta-expanding polymorphic methods does not give more than

scala> def f[A](a: A): A = ???
def f[A](a: A): A

scala> f
val res0: Any => Any = Lambda$7538/1430563609@4a905603

scala> val g: ([A] => A => A) = f
1 |val g: ([A] => A => A) = f
  |                         ^
  |                         Found:    Any => Any
  |                         Required: PolyFunction{apply: [A](x$1: A): A}
Mario Galic
  • 47,285
  • 6
  • 56
  • 98
  • 3
    Uhm not sure if SO is the best place for this question? Wouldn't it be better the contributors' forum? – Luis Miguel Mejía Suárez Apr 06 '21 at 20:57
  • 2
    I mean the answer is either: a) a compiler bug - b) a spec bug - c) this is the expected behaviour because ... - The only ones that can provide that are the contributors of the language, also being that I am very sure it is either a or b I believe a post in their discourse could bring attention so this can be fixed before the final release of `3.0.0` – Luis Miguel Mejía Suárez Apr 06 '21 at 21:23
  • How would you differ: 1) `f` where `A` is specified and then eta-converted as a monomorphic method, 2) `f` where `A` is inferred and then eta-converted as a monomorphic method, 3) `f` eta-converted as a polymorphic method? – Dmytro Mitin Sep 25 '21 at 22:44

0 Answers0