@@ -331,23 +331,37 @@ class ReifyQuotes extends MacroTransform {
331
331
*/
332
332
private def makeHole (isTermHole : Boolean , body : Tree , splices : List [Tree ], tpe : Type )(implicit ctx : Context ): Hole = {
333
333
val idx = embedded.addTree(body, NoSymbol )
334
- val holeType = getHoleType(isTermHole)(tpe)
335
- Hole (isTermHole, idx, splices).withType(holeType).asInstanceOf [Hole ]
336
- }
337
334
338
- private def getHoleType (isTermHole : Boolean )(using ctx : Context ) = new TypeMap () {
339
- override def apply (tp : Type ): Type = tp match
340
- case tp : TypeRef if tp.typeSymbol.isSplice =>
341
- apply(tp.dealias)
342
- case tp @ TypeRef (pre, _) if ! isTermHole && pre == NoPrefix || pre.termSymbol.isLocal =>
343
- val hiBound = tp.typeSymbol.info match
344
- case info @ ClassInfo (_, _, classParents, _, _) => classParents.reduce(_ & _)
345
- case info => info.hiBound
346
- apply(hiBound)
347
- case tp @ TermRef (NoPrefix , _) =>
348
- apply(tp.widenTermRefExpr)
349
- case tp =>
350
- mapOver(tp)
335
+ def getTypeHoleType (using ctx : Context ) = new TypeMap () {
336
+ override def apply (tp : Type ): Type = tp match
337
+ case tp : TypeRef if tp.typeSymbol.isSplice =>
338
+ apply(tp.dealias)
339
+ case tp @ TypeRef (pre, _) if pre == NoPrefix || pre.termSymbol.isLocal =>
340
+ val hiBound = tp.typeSymbol.info match
341
+ case info @ ClassInfo (_, _, classParents, _, _) => classParents.reduce(_ & _)
342
+ case info => info.hiBound
343
+ apply(hiBound)
344
+ case tp @ TermRef (NoPrefix , _) =>
345
+ apply(tp.widenTermRefExpr)
346
+ case tp =>
347
+ mapOver(tp)
348
+ }
349
+
350
+ def getTermHoleType (using ctx : Context ) = new TypeMap () {
351
+ override def apply (tp : Type ): Type = tp match
352
+ case tp @ TypeRef (NoPrefix , _) if capturers.contains(tp.symbol) =>
353
+ // reference to term with a type defined in outer quote
354
+ getTypeHoleType(tp)
355
+ case tp @ TermRef (NoPrefix , _) /* if capturers.contains(tp.symbol)*/ => // TODO needs the guard?
356
+ // widen term refs to terms defined in outer quote
357
+ apply(tp.widenTermRefExpr)
358
+ case tp =>
359
+ mapOver(tp)
360
+ }
361
+
362
+ val holeType = if isTermHole then getTermHoleType(tpe) else getTypeHoleType(tpe)
363
+
364
+ Hole (isTermHole, idx, splices).withType(holeType).asInstanceOf [Hole ]
351
365
}
352
366
353
367
override def transform (tree : Tree )(implicit ctx : Context ): Tree =
0 commit comments