Skip to content

Eta-expansion competes with match type, contextual application #17210

Open
@mbuzdalov

Description

@mbuzdalov

Compiler version

3.2.2

Minimized code

object BugReport:
  trait Executor
  trait Updatable[+A]

  def run(task: Executor ?=> Unit): Unit = {}
  def tupledFunction(a: Int, b: Int): Unit = {}
  def tupledSequence(f: ((Updatable[Int], Updatable[Int])) => Unit): Unit = {}

  type UpdatableMap[T <: Tuple] = T match
    case EmptyTuple => EmptyTuple
    case h *: t => Updatable[h] *: UpdatableMap[t]

  def liftAsTupledInThreads[A <: Tuple](f: A => Unit)(using e: Executor): UpdatableMap[A] => Unit = ???

  run {
    tupledSequence(liftAsTupledInThreads(tupledFunction.tupled))
  }

  run {
    val lifted = liftAsTupledInThreads(tupledFunction.tupled)
    tupledSequence(lifted)
  }

Output

BugReport.scala:16:20
Found:    (e : (BugReport.Updatable[Int], 
  BugReport.Updatable[Int]
))
Required: BugReport.Executor
    tupledSequence(liftAsTupledInThreads(tupledFunction.tupled))

Expectation

Two "run" sections are essentially the same, but the second compiles as expected, and the first fails.

The error message suggests that it swaps the argument of the returned function and the context bound.

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