|
| 1 | + |
| 2 | +object BugReport: |
| 3 | + trait Executor |
| 4 | + trait Updatable[+A] |
| 5 | + |
| 6 | + def run(task: Executor ?=> Unit): Unit = () |
| 7 | + def tupledFunction(a: Int, b: Int): Unit = () |
| 8 | + def tupledSequence(f: ((Updatable[Int], Updatable[Int])) => Unit): Unit = () |
| 9 | + |
| 10 | + type UpdatableMap[T <: Tuple] = T match |
| 11 | + case EmptyTuple => EmptyTuple |
| 12 | + case h *: t => Updatable[h] *: UpdatableMap[t] |
| 13 | + // eliminate the match type |
| 14 | + type xUpdatableMap[_] = (Updatable[Int], Updatable[Int]) |
| 15 | + |
| 16 | + // so that expected type is satisfied, avoid eta-expansion and subsequent error |
| 17 | + transparent inline // presumably allows match type "expansion" before adaptation |
| 18 | + def liftAsTupledInThreads[A <: Tuple](f: A => Unit)(using e: Executor): UpdatableMap[A] => Unit = _ => () |
| 19 | + // eliminate eta-expansion where the partial application returns a context function |
| 20 | + def xliftAsTupledInThreads[A <: Tuple](f: A => Unit): Executor ?=> UpdatableMap[A] => Unit = _ => () |
| 21 | + |
| 22 | + run: |
| 23 | + tupledSequence(liftAsTupledInThreads(tupledFunction.tupled)) // was error |
| 24 | + |
| 25 | + run: |
| 26 | + val lifted = liftAsTupledInThreads(tupledFunction.tupled) |
| 27 | + // the expected type induces the symptom |
| 28 | + //val lifted: ((Updatable[Int], Updatable[Int])) => Unit = liftAsTupledInThreads(tupledFunction.tupled) |
| 29 | + tupledSequence(lifted) |
| 30 | + |
| 31 | +object BugReport2: |
| 32 | + trait Executor |
| 33 | + trait Updatable[+A] |
| 34 | + |
| 35 | + def run(task: Executor ?=> Unit): Unit = () |
| 36 | + def function(a: Int): Unit = () |
| 37 | + def normalSequence(f: Updatable[Int] => Unit): Unit = () |
| 38 | + |
| 39 | + def liftInThreads[A](f: A => Unit)(using e: Executor): Updatable[A] => Unit = _ => () |
| 40 | + |
| 41 | + run: |
| 42 | + normalSequence(liftInThreads(function)) |
0 commit comments