Skip to content

Commit 04bd41e

Browse files
author
gorilskij
committed
add (non-working) macro test case
1 parent ac390f3 commit 04bd41e

File tree

3 files changed

+148
-169
lines changed

3 files changed

+148
-169
lines changed

tests/pos/i8577.scala

Lines changed: 0 additions & 169 deletions
This file was deleted.

tests/pos/i8577/MacroA.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroA:
6+
opaque type SC = scala.StringContext
7+
def apply(ctx: scala.StringContext): SC = ctx
8+
def unapply(ctx: SC): Option[scala.StringContext] = Some(ctx)
9+
10+
extension (ctx: StringContext) def mac: MacroA.SC = MacroA(ctx)
11+
extension (inline ctx: MacroA.SC) inline def apply(inline args: Int*): String = ""
12+
extension (inline ctx: MacroA.SC) inline def unapplySeq(inline input: Int): Option[Seq[Int]] =
13+
${ implUnapply('ctx, 'input) }
14+
15+
def implUnapply(sc: Expr[MacroA.SC], input: Expr[Int])(using Quotes): Expr[Option[Seq[Int]]] =
16+
Expr(Some(Seq(0)))

tests/pos/i8577/Main.scala

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package i8577
2+
3+
def main: Unit = {
4+
{
5+
1 match
6+
case mac"$x" => x
7+
}
8+
}
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
// {
35+
// // B
36+
// object F2
37+
// extension (o: F2.type) inline def unapplySeq[T](inline x: T) = Some(Seq(x))
38+
//
39+
// val F2(x) = 16
40+
// println(s"F2: $x")
41+
// }
42+
//
43+
// {
44+
// // C
45+
// object F1
46+
// extension [T] (o: F1.type) inline def unapplySeq(inline x: T) = Some(Seq(x))
47+
//
48+
// val F1(x) = 15
49+
// println(s"F1: $x")
50+
// }
51+
//
52+
// {
53+
// // D
54+
// object F4b
55+
// extension [T] (o: F4b.type) inline def unapplySeq[U](inline x: T) = Some(Seq(x))
56+
//
57+
// val F4b(x) = 18.2
58+
// println(s"F4b: $x")
59+
// }
60+
//
61+
// {
62+
// // E
63+
// object F4b
64+
// extension [T] (o: F4b.type) inline def unapplySeq[U](inline x: U) = Some(Seq(x))
65+
//
66+
// val F4b(x) = 18.2
67+
// println(s"F4b: $x")
68+
// }
69+
//
70+
// {
71+
// // F
72+
// object F4d
73+
// extension [T] (o: F4d.type) inline def unapplySeq[U](inline x: (T, U)) = Some(Seq(x))
74+
//
75+
// val F4d(x) = (18.4, 18.5)
76+
// println(s"F4d: $x")
77+
// }
78+
//
79+
// {
80+
// // G
81+
// object H1
82+
// extension (inline o: H1.type) inline def unapplySeq(inline x: Int) = Some(Seq(x))
83+
//
84+
// val H1(x) = 23
85+
// println(s"H1: $x")
86+
// }
87+
//
88+
// {
89+
// // H
90+
// object H2
91+
// extension (inline o: H2.type) inline def unapplySeq[T](inline x: T) = Some(Seq(x))
92+
//
93+
// val H2(x) = 24
94+
// println(s"H2: $x")
95+
// }
96+
//
97+
// {
98+
// // I
99+
// object H2
100+
// extension [T] (inline o: H2.type) inline def unapplySeq(inline x: T) = Some(Seq(x))
101+
//
102+
// val H2(x) = 24
103+
// println(s"H2: $x")
104+
// }
105+
//
106+
// {
107+
// // J
108+
// object H2
109+
// extension [T] (inline o: H2.type) inline def unapplySeq[U](inline x: T) = Some(Seq(x))
110+
//
111+
// val H2(x) = 24
112+
// println(s"H2: $x")
113+
// }
114+
//
115+
// {
116+
// // K
117+
// object H2
118+
// extension [T] (inline o: H2.type) inline def unapplySeq[U](inline x: U) = Some(Seq(x))
119+
//
120+
// val H2(x) = 24
121+
// println(s"H2: $x")
122+
// }
123+
//
124+
// {
125+
// // L
126+
// object H2
127+
// extension [T] (inline o: H2.type) inline def unapplySeq[U](inline x: (T, U)) = Some(Seq(x))
128+
//
129+
// val H2(x) = (24, "a")
130+
// println(s"H2: $x")
131+
// }
132+
//}

0 commit comments

Comments
 (0)