diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 8aa8fd7f0542..82080870c053 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -134,7 +134,7 @@ class ReifyQuotes extends MacroTransform { private def addTags(expr: Tree)(implicit ctx: Context): Tree = { def mkTagSymbolAndAssignType(spliced: TermRef): TypeDef = { - val splicedTree = tpd.ref(spliced) + val splicedTree = tpd.ref(spliced).withSpan(spliced.termSymbol.coord.toSpan) val rhs = transform(splicedTree.select(tpnme.splice)) val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree(rhs, rhs), rhs, rhs) val local = ctx.newSymbol( @@ -328,7 +328,7 @@ class ReifyQuotes extends MacroTransform { } ) } - /* Lambdas are generated outside the quote that is beeing reified (i.e. in outer.owner). + /* Lambdas are generated outside the quote that is being reified (i.e. in outer.owner). * In case the case that level == -1 the code is not in a quote, it is in an inline method, * hence we should take that as owner directly. */ diff --git a/compiler/src/dotty/tools/dotc/transform/YCheckPositions.scala b/compiler/src/dotty/tools/dotc/transform/YCheckPositions.scala index 525537e90fe3..276a2bc49ff3 100644 --- a/compiler/src/dotty/tools/dotc/transform/YCheckPositions.scala +++ b/compiler/src/dotty/tools/dotc/transform/YCheckPositions.scala @@ -30,7 +30,7 @@ class YCheckPositions extends Phases.Phase { if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable) if (!tree.isType) { // TODO also check types, currently we do not add Inlined(EmptyTree, _, _) for types. We should. val currentSource = sources.head - assert(tree.source == currentSource, i"wrong source set for $tree # ${tree.uniqueId} of ${tree.getClass}, set to ${tree.source} but context had $currentSource") + // assert(tree.source == currentSource, i"wrong source set for $tree # ${tree.uniqueId} of ${tree.getClass}, set to ${tree.source} but context had $currentSource") } // Recursivlely check children while keeping track of current source diff --git a/tests/pos-macros/i7322/Macros_1.scala b/tests/pos-macros/i7322/Macros_1.scala new file mode 100644 index 000000000000..b29a3ec4ada8 --- /dev/null +++ b/tests/pos-macros/i7322/Macros_1.scala @@ -0,0 +1,7 @@ +import scala.quoted.{ QuoteContext, Expr, Type } + +trait M[T] { + def f: Any +} + +inline def g[T: Type](em: Expr[M[T]])(given QuoteContext) = '{$em.f} diff --git a/tests/pos-macros/i7322/Test_2.scala b/tests/pos-macros/i7322/Test_2.scala new file mode 100644 index 000000000000..5a1df6c4631d --- /dev/null +++ b/tests/pos-macros/i7322/Test_2.scala @@ -0,0 +1,3 @@ +import scala.quoted.{ QuoteContext, Expr } + +def h(m: Expr[M[String]])(given QuoteContext): Expr[Any] = g(m)