Skip to content

Fix owner of splices in class statements #18359

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
Aug 9, 2023
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: 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