@@ -188,15 +188,19 @@ class Splicing extends MacroTransform:
188188 * ```
189189 */
190190 private class SpliceTransformer (spliceOwner : Symbol , isCaptured : Symbol => Boolean ) extends Transformer :
191- private var refBindingMap = mutable.Map .empty[Symbol , (Tree , Symbol )]
191+ private val typeBindingMap = mutable.Map .empty[Symbol , (Tree , Symbol )]
192+ private val termBindingMap = mutable.Map .empty[Symbol , (Tree , Symbol )]
192193 /** Reference to the `Quotes` instance of the current level 1 splice */
193194 private var quotes : Tree | Null = null // TODO: add to the context
194195 private var healedTypes : QuoteTypeTags | Null = null // TODO: add to the context
195196
196197 def transformSplice (tree : tpd.Tree , tpe : Type , holeIdx : Int )(using Context ): tpd.Tree =
197198 assert(level == 0 )
198199 val newTree = transform(tree)
199- val (refs, bindings) = refBindingMap.values.toList.unzip
200+ val (typeRefs, typeBindings) = typeBindingMap.values.toList.unzip
201+ val (termRefs, termBindings) = termBindingMap.values.toList.unzip
202+ val refs = typeRefs ::: termRefs
203+ val bindings = typeBindings ::: termBindings
200204 val bindingsTypes = bindings.map(_.termRef.widenTermRefExpr)
201205 val methType = MethodType (bindingsTypes, newTree.tpe)
202206 val meth = newSymbol(spliceOwner, nme.ANON_FUN , Synthetic | Method , methType)
@@ -348,7 +352,7 @@ class Splicing extends MacroTransform:
348352 Param ,
349353 defn.QuotedExprClass .typeRef.appliedTo(tpe),
350354 )
351- val bindingSym = refBindingMap .getOrElseUpdate(tree.symbol, (tree, newBinding))._2
355+ val bindingSym = termBindingMap .getOrElseUpdate(tree.symbol, (tree, newBinding))._2
352356 ref(bindingSym)
353357
354358 private def newQuotedTypeClassBinding (tpe : Type )(using Context ) =
@@ -361,7 +365,7 @@ class Splicing extends MacroTransform:
361365
362366 private def capturedType (tree : Tree )(using Context ): Symbol =
363367 val tpe = tree.tpe.widenTermRefExpr
364- val bindingSym = refBindingMap
368+ val bindingSym = typeBindingMap
365369 .getOrElseUpdate(tree.symbol, (TypeTree (tree.tpe), newQuotedTypeClassBinding(tpe)))._2
366370 bindingSym
367371
@@ -371,7 +375,7 @@ class Splicing extends MacroTransform:
371375 val capturePartTypes = new TypeMap {
372376 def apply (tp : Type ) = tp match {
373377 case typeRef : TypeRef if containsCapturedType(typeRef) =>
374- val termRef = refBindingMap
378+ val termRef = typeBindingMap
375379 .getOrElseUpdate(typeRef.symbol, (TypeTree (typeRef), newQuotedTypeClassBinding(typeRef)))._2.termRef
376380 val tagRef = healedTypes.nn.getTagRef(termRef)
377381 tagRef
0 commit comments