@@ -3565,9 +3565,9 @@ class Typer extends Namer
3565
3565
/** Types the body Scala 2 macro declaration `def f = macro <body>` */
3566
3566
private def typedScala2MacroBody (call : untpd.Tree )(using Context ): Tree =
3567
3567
// TODO check that call is to a method with valid signature
3568
- def typedPrefix (tree : untpd.RefTree ): Tree = {
3568
+ def typedPrefix (tree : untpd.RefTree )( splice : Context ?=> Tree => Tree )( using Context ) : Tree = {
3569
3569
tryAlternatively {
3570
- typedExpr(tree, defn.AnyType )
3570
+ splice( typedExpr(tree, defn.AnyType ) )
3571
3571
} {
3572
3572
// Try to type as a macro bundle
3573
3573
val ref = tree match
@@ -3576,19 +3576,23 @@ class Typer extends Namer
3576
3576
val bundle = untpd.Apply (untpd.Select (untpd.New (ref), nme.CONSTRUCTOR ), untpd.Literal (Constant (null ))).withSpan(call.span)
3577
3577
val bundle1 = typedExpr(bundle, defn.AnyType )
3578
3578
val bundleVal = SyntheticValDef (NameKinds .UniqueName .fresh(" bundle" .toTermName), bundle1)
3579
- tpd.Block (List (bundleVal), tpd.ref(bundleVal.symbol))
3579
+ tpd.Block (List (bundleVal), splice( tpd.ref(bundleVal.symbol) ))
3580
3580
}
3581
3581
}
3582
3582
if ctx.phase.isTyper then
3583
3583
call match
3584
3584
case call : untpd.Ident =>
3585
3585
typedIdent(call, defn.AnyType )
3586
3586
case untpd.Select (qual : untpd.RefTree , name) =>
3587
- val call2 = untpd.Select (untpd.TypedSplice (typedPrefix(qual)), name).withSpan(call.span)
3588
- typedSelect(call2, defn.AnyType )
3587
+ typedPrefix(qual) { qual =>
3588
+ val call2 = untpd.Select (untpd.TypedSplice (qual), name).withSpan(call.span)
3589
+ typedSelect(call2, defn.AnyType )
3590
+ }
3589
3591
case untpd.TypeApply (untpd.Select (qual : untpd.RefTree , name), targs) =>
3590
- val call2 = untpd.TypeApply (untpd.Select (untpd.TypedSplice (typedPrefix(qual)), name), targs).withSpan(call.span)
3591
- typedTypeApply(call2, defn.AnyType )
3592
+ typedPrefix(qual) { qual =>
3593
+ val call2 = untpd.TypeApply (untpd.Select (untpd.TypedSplice (qual), name), targs).withSpan(call.span)
3594
+ typedTypeApply(call2, defn.AnyType )
3595
+ }
3592
3596
case _ =>
3593
3597
ctx.error(" Invalid Scala 2 macro " + call.show, call.sourcePos)
3594
3598
EmptyTree
0 commit comments