Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
Closes #16420
  • Loading branch information
nicolasstucki committed Nov 28, 2022
1 parent c715a47 commit 366b239
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/pos-macros/i16420/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import scala.quoted.{Expr, Quotes, Type}

object Converter {
private def handleUnit[R](f: Expr[Int ?=> R])(using q: Quotes, rt: Type[R]): Expr[Unit] = '{}

class UnitConverter[R] extends Converter[EmptyTuple, R, Int ?=> R] {
inline def convert(inline f: Int ?=> R): Unit = ${ handleUnit[R]('f) }
}

inline given unitHandler[R]: UnitConverter[R] = new UnitConverter[R]
}


trait Converter[T <: Tuple, R, F] {
inline def convert(inline fn: F): Unit
}

abstract class Directive[R <: Tuple] {
inline def apply[O, F](using inline c: Converter[R, O, F])(inline fn: F): Unit =
c.convert(fn)
}
8 changes: 8 additions & 0 deletions tests/pos-macros/i16420/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object Meow extends App {
case class Meow(s: String, i: Int)

val dir: Directive[EmptyTuple] = ???
dir {
Meow("asd", 123)
}
}

0 comments on commit 366b239

Please sign in to comment.