Skip to content

Fix #8325: Add missing span #8328

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
merged 1 commit into from
Feb 17, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class StringInterpolatorOpt extends MiniPhase {
val elemi = elems.iterator
var result: Tree = stri.next
def concat(tree: Tree): Unit = {
result = result.select(defn.String_+).appliedTo(tree)
result = result.select(defn.String_+).appliedTo(tree).withSpan(tree.span)
}
while (elemi.hasNext) {
concat(elemi.next)
Expand Down
21 changes: 21 additions & 0 deletions tests/pos-macros/i8325/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package a

import scala.quoted._
import scala.quoted.matching._

object A:

inline def transform[A](inline expr: A): A = ${
transformImplExpr('expr)
}

def pure[A](a:A):A = ???

def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
import qctx.tasty.{given _, _}
expr.unseal match {
case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]])
case Apply(fun,args) => '{ A.pure(${Apply(fun,args).seal.asInstanceOf[Expr[A]]}) }
case other => expr
}
}
10 changes: 10 additions & 0 deletions tests/pos-macros/i8325/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package a

class Test1 {

def t1(): Unit = {
A.transform(
s"a ${1} ${2}")
}

}
22 changes: 22 additions & 0 deletions tests/pos-macros/i8325b/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package a

import scala.quoted._
import scala.quoted.matching._

object A:

inline def transform[A](inline expr: A): A = ${
transformImplExpr('expr)
}

def pure[A](a:A):A = ???

def transformImplExpr[A:Type](using qctx: QuoteContext)(expr: Expr[A]): Expr[A] = {
import qctx.tasty.{given _, _}
expr.unseal match {
case Inlined(x,y,z) => transformImplExpr(z.seal.asInstanceOf[Expr[A]])
case r@Apply(fun,args) => '{
A.pure(${r.seal.asInstanceOf[Expr[A]]}) }
case other => expr
}
}
10 changes: 10 additions & 0 deletions tests/pos-macros/i8325b/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package a

class Test1 {

def t1(): Unit = {
A.transform(
s"a ${1} ${2}")
}

}