Skip to content

Commit 366b239

Browse files
committed
Add regression test
Closes #16420
1 parent c715a47 commit 366b239

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/pos-macros/i16420/Macro.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import scala.quoted.{Expr, Quotes, Type}
2+
3+
object Converter {
4+
private def handleUnit[R](f: Expr[Int ?=> R])(using q: Quotes, rt: Type[R]): Expr[Unit] = '{}
5+
6+
class UnitConverter[R] extends Converter[EmptyTuple, R, Int ?=> R] {
7+
inline def convert(inline f: Int ?=> R): Unit = ${ handleUnit[R]('f) }
8+
}
9+
10+
inline given unitHandler[R]: UnitConverter[R] = new UnitConverter[R]
11+
}
12+
13+
14+
trait Converter[T <: Tuple, R, F] {
15+
inline def convert(inline fn: F): Unit
16+
}
17+
18+
abstract class Directive[R <: Tuple] {
19+
inline def apply[O, F](using inline c: Converter[R, O, F])(inline fn: F): Unit =
20+
c.convert(fn)
21+
}

tests/pos-macros/i16420/Test.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Meow extends App {
2+
case class Meow(s: String, i: Int)
3+
4+
val dir: Directive[EmptyTuple] = ???
5+
dir {
6+
Meow("asd", 123)
7+
}
8+
}

0 commit comments

Comments
 (0)