Skip to content

Add String interpolation position regression test #6174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/neg/tasty-string-interpolator-position-a.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<46..65> in Test_2.scala
there are no parts
21 changes: 21 additions & 0 deletions tests/neg/tasty-string-interpolator-position-a/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import scala.quoted._
import scala.tasty.Reflection
import scala.language.implicitConversions
import scala.quoted.Exprs.LiftedExpr
import scala.quoted.Toolbox.Default._

object Macro {

implicit inline def (strCtx: => StringContext) f2 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}

}

object FIntepolator {

def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
import reflect._
error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos)
'{ ($strCtxExpr).s($argsExpr: _*) }
}

}
8 changes: 8 additions & 0 deletions tests/neg/tasty-string-interpolator-position-a/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import Macro._

object Test extends App {

new StringContext().f2() // error

}
2 changes: 2 additions & 0 deletions tests/neg/tasty-string-interpolator-position-b.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<65..65> in Test_2.scala
there are no args
21 changes: 21 additions & 0 deletions tests/neg/tasty-string-interpolator-position-b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import scala.quoted._
import scala.tasty.Reflection
import scala.language.implicitConversions
import scala.quoted.Exprs.LiftedExpr
import scala.quoted.Toolbox.Default._

object Macro {

implicit inline def (strCtx: => StringContext) f3 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}

}

object FIntepolator {

def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
import reflect._
error("there are no args", argsExpr.unseal.underlyingArgument.pos)
'{ ($strCtxExpr).s($argsExpr: _*) }
}

}
8 changes: 8 additions & 0 deletions tests/neg/tasty-string-interpolator-position-b/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import Macro._

object Test extends App {

new StringContext().f3() // error

}