Skip to content

Commit

Permalink
Fix owner of spices in class statements
Browse files Browse the repository at this point in the history
Fixes #18358

[Cherry-picked 525e93c]
  • Loading branch information
nicolasstucki authored and Kordyjan committed Dec 7, 2023
1 parent 0c0b48d commit 5a4d683
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object PickledQuotes {

/** Replace all term holes with the spliced terms */
private def spliceTerms(tree: Tree, typeHole: TypeHole, termHole: ExprHole)(using Context): Tree = {
def evaluateHoles = new TreeMap {
def evaluateHoles = new TreeMapWithPreciseStatContexts {
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
case Hole(isTerm, idx, args, _) =>
inContext(SpliceScope.contextWithNewSpliceScope(tree.sourcePos)) {
Expand Down
4 changes: 4 additions & 0 deletions tests/pos-macros/i18358/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import scala.quoted.*
inline def generateCode: Unit = ${ testLocalDummyOwner }
def testLocalDummyOwner(using Quotes): Expr[Unit] = '{ trait E { $valInBlock } }
def valInBlock(using Quotes): Expr[Unit] = '{ val x: Int = 2; () }
1 change: 1 addition & 0 deletions tests/pos-macros/i18358/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def test = generateCode

0 comments on commit 5a4d683

Please sign in to comment.