@@ -52,13 +52,14 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
52
52
protected def transformSplice (body : Tree , splice : Tree )(implicit ctx : Context ): Tree = {
53
53
if (level >= 1 ) {
54
54
val body1 = transform(body)(spliceContext)
55
- val splice1 = splice match {
56
- case splice : Apply => cpy.Apply (splice)(splice.fun, body1 :: Nil )
55
+ splice match {
56
+ case Apply (fun : TypeApply , _) if splice.isTerm =>
57
+ // Type of the splice itsel must also be healed
58
+ // internal.Quoted.expr[F[T]](... T ...) --> internal.Quoted.expr[F[$t]](... T ...)
59
+ val tp = checkType(splice.sourcePos).apply(splice.tpe.widenTermRefExpr)
60
+ cpy.Apply (splice)(cpy.TypeApply (fun)(fun.fun, tpd.TypeTree (tp) :: Nil ), body1 :: Nil )
57
61
case splice : Select => cpy.Select (splice)(body1, splice.name)
58
62
}
59
-
60
- if (splice1.isType) splice1
61
- else addSpliceCast(splice1)
62
63
}
63
64
else {
64
65
assert(! enclosingInlineds.nonEmpty, " unexpanded macro" )
@@ -76,15 +77,6 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
76
77
}
77
78
}
78
79
79
-
80
- /** Add cast to force boundaries where T and $t (an alias of T) are used to ensure PCP.
81
- * '{ ${...: T} } --> '{ ${...: T}.asInstanceOf[T] } --> '{ ${...: T}.asInstanceOf[$t] }
82
- */
83
- protected def addSpliceCast (tree : Tree )(implicit ctx : Context ): Tree = {
84
- val tp = checkType(tree.sourcePos).apply(tree.tpe.widenTermRefExpr)
85
- tree.cast(tp).withSpan(tree.span)
86
- }
87
-
88
80
/** If `tree` refers to a locally defined symbol (either directly, or in a pickled type),
89
81
* check that its staging level matches the current level. References to types
90
82
* that are phase-incorrect can still be healed as follows:
0 commit comments