File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ import scala .quoted .*
2+
3+ trait Hammer [I , O ] {
4+ def hammer (input : I ): O
5+ }
6+
7+ object Hammer {
8+ inline def makeProductHammerMacro [I , O ](): Hammer [I , O ] =
9+ $ { makeProductHammerMacroImpl[I , O ] }
10+
11+ def makeProductHammerMacroImpl [I : Type , O : Type ](using Quotes ): Expr [Hammer [I , O ]] =
12+ ' { makeHammer[I , O ]() }
13+
14+ inline def makeHammer [S , O ](): Hammer [S , O ] =
15+ new Hammer [S , O ] {
16+ lazy val (hammer : Hammer [? , Int ], idx : Int ) = ???
17+
18+ override def hammer (input : S ): O = {
19+ hammer.hammer(??? .asInstanceOf ).asInstanceOf [O ]
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ object HammerSpec {
2+ case class A (x : Int )
3+ case class B (x : Int )
4+ Hammer .makeProductHammerMacro[A , B ]()
5+ }
You can’t perform that action at this time.
0 commit comments