Skip to content

Commit 8042c00

Browse files
committed
Fix #7887: Add regression test
1 parent a6b8a98 commit 8042c00

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

tests/pos/i7887.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def typed[A](given t: quoted.Type[A], qctx: quoted.QuoteContext): Unit = {
2+
import qctx.tasty.{given, _}
3+
'{
4+
type T = $t
5+
${'{???}.cast[T]}
6+
}
7+
}

tests/run-macros/i7887/Macro_1.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def myMacroImpl(a: quoted.Expr[_])(given qctx: quoted.QuoteContext) = {
2+
import qctx.tasty.{_, given}
3+
def typed[A] = {
4+
implicit val t: quoted.Type[A] = a.unseal.tpe.widen.seal.asInstanceOf[quoted.Type[A]]
5+
'{
6+
type T = $t
7+
${a.unseal.seal.cast[T]}
8+
}
9+
}
10+
11+
typed
12+
}
13+
14+
15+
inline def myMacro(a: => Any) = ${
16+
myMacroImpl('a)
17+
}

tests/run-macros/i7887/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test extends App {
2+
assert(myMacro(42) == 42)
3+
}

0 commit comments

Comments
 (0)