Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2e4c2ae

Browse files
committedMay 27, 2025·
Test inline method returning match type
1 parent 2703b6b commit 2e4c2ae

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
 

‎tests/pos/i17210.scala

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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
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)) // 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

Comments
 (0)
Please sign in to comment.