Skip to content

Commit a9ef81f

Browse files
Merge pull request #6174 from dotty-staging/add-string-interpolation-position-regression-test
Add String interpolation position regression test
2 parents eecd672 + f4fdb22 commit a9ef81f

File tree

6 files changed

+62
-0
lines changed

6 files changed

+62
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<46..65> in Test_2.scala
2+
there are no parts
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import scala.quoted._
2+
import scala.tasty.Reflection
3+
import scala.language.implicitConversions
4+
import scala.quoted.Exprs.LiftedExpr
5+
import scala.quoted.Toolbox.Default._
6+
7+
object Macro {
8+
9+
implicit inline def (strCtx: => StringContext) f2 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
10+
11+
}
12+
13+
object FIntepolator {
14+
15+
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
16+
import reflect._
17+
error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos)
18+
'{ ($strCtxExpr).s($argsExpr: _*) }
19+
}
20+
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
import Macro._
3+
4+
object Test extends App {
5+
6+
new StringContext().f2() // error
7+
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<65..65> in Test_2.scala
2+
there are no args
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import scala.quoted._
2+
import scala.tasty.Reflection
3+
import scala.language.implicitConversions
4+
import scala.quoted.Exprs.LiftedExpr
5+
import scala.quoted.Toolbox.Default._
6+
7+
object Macro {
8+
9+
implicit inline def (strCtx: => StringContext) f3 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
10+
11+
}
12+
13+
object FIntepolator {
14+
15+
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
16+
import reflect._
17+
error("there are no args", argsExpr.unseal.underlyingArgument.pos)
18+
'{ ($strCtxExpr).s($argsExpr: _*) }
19+
}
20+
21+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
import Macro._
3+
4+
object Test extends App {
5+
6+
new StringContext().f3() // error
7+
8+
}

0 commit comments

Comments
 (0)