diff --git a/library/src/scala/tasty/reflect/SourceCodePrinter.scala b/library/src/scala/tasty/reflect/SourceCodePrinter.scala index 75da3d55750b..6397c9b09773 100644 --- a/library/src/scala/tasty/reflect/SourceCodePrinter.scala +++ b/library/src/scala/tasty/reflect/SourceCodePrinter.scala @@ -1123,7 +1123,10 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig case AppliedType(tp, args) => tp match { case tp: TypeLambda => - printType(tpe.dealias) + this += "(" + printType(tp) + this += ")" + inSquare(printTypesOrBounds(args, ", ")) case tp: TypeRef if tp.typeSymbol == ctx.requiredClass("scala.") => this += "_*" case _ => diff --git a/tests/pos-macros/i9251/Macro_1.scala b/tests/pos-macros/i9251/Macro_1.scala new file mode 100644 index 000000000000..2e9ccf5685cf --- /dev/null +++ b/tests/pos-macros/i9251/Macro_1.scala @@ -0,0 +1,34 @@ +package cps + +import scala.quoted._ + +trait CpsMonad[F[_]] + +trait ComputationBound[T] + +implicit object ComputationBoundMonad extends CpsMonad[ComputationBound] + +inline def async[F[_]](using am:CpsMonad[F]): Async.InferAsyncArg[F] = + new Async.InferAsyncArg[F] + +object Async { + + class InferAsyncArg[F[_]](using am:CpsMonad[F]) { + inline def apply[T](inline expr: T):Unit = ${ Async.checkPrintTypeImpl[F,T]('expr) } + } + + + def checkPrintTypeImpl[F[_]:Type,T:Type](f: Expr[T])(using qctx: QuoteContext): Expr[Unit] = + import qctx.tasty._ + + val fu = f.unseal + fu match + case Inlined(_,_,Block(_,Apply(TypeApply(Select(q,n),tparams),List(param)))) => + param.tpe match + case AppliedType(tp,tparams1) => + val fType = summon[quoted.Type[F]] + val ptp = tparams1.tail.head + val ptpTree = Inferred(AppliedType(fType.unseal.tpe,List(ptp))) + '{ println(${Expr(ptpTree.show)}) } + +} diff --git a/tests/pos-macros/i9251/Test_2.scala b/tests/pos-macros/i9251/Test_2.scala new file mode 100644 index 000000000000..a7a6bea23545 --- /dev/null +++ b/tests/pos-macros/i9251/Test_2.scala @@ -0,0 +1,5 @@ +package cps + +val c = async[ComputationBound] { + List(1,2,3,4).collectFirst { case x if x > 0 => x > 3 } +}