Skip to content

Adaptation to Unit is not performed after eta-expansion #24726

@hamzaremmal

Description

@hamzaremmal

Compiler version

ba45875

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))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions