scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Adaptation to Unit is not performed after eta-expansion

Open hamzaremmal opened this issue 1 day ago • 2 comments

Compiler version

ba4587574519c8a80c07504e53a9157815a69503

Minimized code

def bar[A](f: A => Unit): A = ???
def foo[A, U](f: A => U): A = bar(f)

Output

-- [E007] Type Mismatch Error: test.scala:2:34 ---------------------------------
2 |def foo[A, U](f: A => U): A = bar(f)
  |                                  ^
  |                                  Found:    (f : A => U)
  |                                  Required: A => Unit
  |
  | longer explanation available when compiling with `-explain`

Expectation

Should compile. It was mentioned during our lab meeting last week that we do perform adaptation after eta-expansion.

Notes

If we expand manually, the code compiles.

def bar[A](f: A => Unit): A = ???
def foo[A, U](f: A => U): A = bar(x => f(x))

hamzaremmal avatar Dec 11 '25 00:12 hamzaremmal