Skip to content
Open
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: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ object Splicer {
case tree: Inlined if tree.inlinedFromOuterScope => tree.expansion
case _ => body
}
new ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(body1, ctx.owner)).withSpan(body1.span), SpliceScope.getCurrent)
new ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(body1, ctx.owner)).cloneIn(body1.source).withSpan(body1.span), SpliceScope.getCurrent)

// Interpret level -1 `Type.of[T]`
case Apply(TypeApply(fn, quoted :: Nil), _) if fn.symbol == defn.QuotedTypeModule_of =>
Expand Down
3 changes: 3 additions & 0 deletions tests/run-macros/i21910.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
70..71 of tests/run-macros/i21910/Outer.scala with length 73
70..71 of tests/run-macros/i21910/Outer.scala with length 73
44..57 of tests/run-macros/i21910/Main.scala with length 58
16 changes: 16 additions & 0 deletions tests/run-macros/i21910/Inner.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import scala.quoted.*

object Inner:
inline def pos(inline x: Any): Unit =
${ posImpl('x) }

def posImpl(x: Expr[Any])(using Quotes): Expr[Unit] =
import quotes.reflect.*
def printPos(p: Position): Expr[Unit] =
val str = Expr(s"${p.start}..${p.end} of ${p.sourceFile.path} with length ${p.sourceFile.content.get.length}")
'{println($str)}
'{
${printPos(x.asTerm.pos)}
${printPos(x.asTerm.asInstanceOf[Inlined].body.pos)}
${printPos(x.asTerm.asInstanceOf[Inlined].body.asInstanceOf[Inlined].body.pos)}
}
3 changes: 3 additions & 0 deletions tests/run-macros/i21910/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@main def Test(): Unit =
Outer.outer:
println("hi")
3 changes: 3 additions & 0 deletions tests/run-macros/i21910/Outer.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Outer:
inline def outer(inline x: Any): Unit =
Inner.pos(x)
Loading