From 5176fb99a4ded37a7eb38eaf36c5999dca29b325 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 3 Oct 2019 08:52:05 +0200 Subject: [PATCH] Fix #7358: Add missing span to spliced tree --- .../dotty/tools/dotc/transform/ReifyQuotes.scala | 2 +- tests/pos/i7358.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i7358.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index b17efa5c5e22..ceeff4f42ddb 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(expr.span) val rhs = transform(splicedTree.select(tpnme.splice)) val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree(rhs, rhs), rhs, rhs) val local = ctx.newSymbol( diff --git a/tests/pos/i7358.scala b/tests/pos/i7358.scala new file mode 100644 index 000000000000..9a20680bed76 --- /dev/null +++ b/tests/pos/i7358.scala @@ -0,0 +1,16 @@ +package test + +import scala.quoted._ +import scala.compiletime._ + +inline def summonT[Tp <: Tuple] <: Tuple = inline erasedValue[Tp] match { + case _ : Unit => () + case _ : (hd *: tl) => { + type H = hd + summonFrom { + case given _ : Type[H] => summon[Type[H]] *: summonT[tl] + } + } +} + +def test[T : Type] = summonT[Tuple1[List[T]]]