Skip to content

Commit e7a74e4

Browse files
author
gorilskij
committed
Merge branch 'non-working-test-case'
2 parents 04bd41e + ea9b46f commit e7a74e4

File tree

9 files changed

+131
-30
lines changed

9 files changed

+131
-30
lines changed

tests/pos/i8577/MacroA.scala

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

tests/pos/i8577/MacroA_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroA:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyA(sc: Expr[MacroB.StringContext], input: Expr[Int])
11+
(using Quotes): Expr[Option[Seq[Int]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroB_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroB:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyB[U](sc: Expr[MacroB.StringContext], input: Expr[U])
11+
(using Type[U])(using Quotes): Expr[Option[Seq[U]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroC_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroC:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyC[T](sc: Expr[MacroC.StringContext], input: Expr[T])
11+
(using Type[T])(using Quotes): Expr[Option[Seq[T]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroD_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroD:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyD[T, U](sc: Expr[MacroD.StringContext], input: Expr[T])
11+
(using Type[T])(using Quotes): Expr[Option[Seq[T]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroE_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroE:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyE[T, U](sc: Expr[MacroE.StringContext], input: Expr[U])
11+
(using Type[U])(using Quotes): Expr[Option[Seq[U]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroF_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroF:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyF[T, U](sc: Expr[MacroF.StringContext], input: Expr[(T, U)])
11+
(using Type[T], Type[U])(using Quotes): Expr[Option[Seq[(T, U)]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/MacroG_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package i8577
2+
3+
import scala.quoted._
4+
5+
object MacroG:
6+
opaque type StringContext = scala.StringContext
7+
def apply(ctx: scala.StringContext): StringContext = ctx
8+
def unapply(ctx: StringContext): Option[scala.StringContext] = Some(ctx)
9+
10+
def implUnapplyG[T, U](sc: Expr[MacroG.StringContext], input: Expr[T | U])
11+
(using Type[T], Type[U])(using Quotes): Expr[Option[Seq[T | U]]] =
12+
'{ Some(Seq(${input})) }

tests/pos/i8577/Main.scala renamed to tests/pos/i8577/Main_2.scala

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,67 @@ package i8577
22

33
def main: Unit = {
44
{
5-
1 match
6-
case mac"$x" => x
7-
}
8-
}
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
5+
extension (ctx: StringContext) def macroA: MacroB.StringContext = MacroB(ctx)
6+
extension (inline ctx: MacroB.StringContext) inline def unapplySeq(inline input: Int): Option[Seq[Int]] =
7+
${implUnapplyA('ctx, 'input)}
198

9+
val macroA"$xA" = 1
10+
}
2011

12+
{
13+
extension (ctx: StringContext) def macroB: MacroB.StringContext = MacroB(ctx)
14+
extension (inline ctx: MacroB.StringContext) inline def unapplySeq[U](inline input: U): Option[Seq[U]] =
15+
${ implUnapplyB('ctx, 'input) }
2116

17+
val macroB"$xB" = 2
18+
}
2219

20+
{
21+
extension (ctx: StringContext) def macroC: MacroC.StringContext = MacroC(ctx)
22+
extension [T] (inline ctx: MacroC.StringContext) inline def unapplySeq(inline input: T): Option[Seq[T]] =
23+
${ implUnapplyC('ctx, 'input) }
2324

25+
// compiler error
26+
// val macroC"$xC" = 3
27+
}
2428

29+
{
30+
extension (ctx: StringContext) def macroD: MacroD.StringContext = MacroD(ctx)
31+
extension [T] (inline ctx: MacroD.StringContext) inline def unapplySeq[U](inline input: T): Option[Seq[T]] =
32+
${ implUnapplyD('ctx, 'input) }
2533

34+
// miscompilation
35+
// val macroD"$xD" = 4
36+
}
2637

38+
{
39+
extension (ctx: StringContext) def macroE: MacroE.StringContext = MacroE(ctx)
40+
extension [T] (inline ctx: MacroE.StringContext) inline def unapplySeq[U](inline input: U): Option[Seq[U]] =
41+
${ implUnapplyE('ctx, 'input) }
2742

43+
val macroE"$xE" = 5
44+
}
2845

46+
{
47+
extension (ctx: StringContext) def macroF: MacroF.StringContext = MacroF(ctx)
48+
extension [T] (inline ctx: MacroF.StringContext) inline def unapplySeq[U](inline input: (T, U)): Option[Seq[(T, U)]] =
49+
${ implUnapplyF('ctx, 'input) }
2950

51+
val macroF"$xF" = (6, 7)
3052

53+
// miscompilation
54+
// val macroF"$xF" = (6, "7")
55+
}
3156

57+
{
58+
extension (ctx: StringContext) def macroG: MacroG.StringContext = MacroG(ctx)
59+
extension [T] (inline ctx: MacroG.StringContext) inline def unapplySeq[U](inline input: T | U): Option[Seq[T | U]] =
60+
${ implUnapplyG('ctx, 'input) }
3261

62+
// compiler error
63+
// val macroG"$xG" = 8
64+
}
65+
}
3366

3467
// {
3568
// // B

0 commit comments

Comments
 (0)