Skip to content
Closed
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
12 changes: 10 additions & 2 deletions compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ object PickledQuotes {

// We need to make sure a hole is created with the source file of the surrounding context, even if
// it filled with contents a different source file.
if filled.source == ctx.source then filled
else filled.cloneIn(ctx.source).withSpan(tree.span)
val sourceReassigner = new TreeMapWithImplicits {
override def transform(innerTree: tpd.Tree)(using Context) = {
innerTree match
case EmptyTree => innerTree // cannot change span of EmptyTree
case _ =>
if innerTree.source == tree.source then innerTree
else super.transform(innerTree.cloneIn(tree.source).withSpan(tree.span))
}
}
sourceReassigner.transform(filled)
else
// For backwards compatibility with 3.0.x and 3.1.x
// In 3.2.0+ all these holes are handled by `spliceTypes` before we call `spliceTerms`.
Expand Down
13 changes: 13 additions & 0 deletions scaladoc-testcases/src/tests/i22265/macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import scala.quoted._

object TestBuilder:
// transparent is needed
transparent inline def apply(inline expr: Unit): Any =
${ TestBuilder.processTests('expr) }

def processTests(using Quotes)(body: Expr[Unit]): Expr[Any] =
import quotes.reflect._
body.asTerm match {
case Inlined(_, _, bindings) =>
'{ ${bindings.asExpr}; () }
}
4 changes: 4 additions & 0 deletions scaladoc-testcases/src/tests/i22265/main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object breaks {
TestBuilder:
import List.empty
}
Loading