@@ -1082,21 +1082,27 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
1082
1082
/** A key to be used in a context property that tracks enclosing inlined calls */
1083
1083
private val InlinedCalls = new Property .Key [List [Tree ]]
1084
1084
1085
- override def inlineContext (call : Tree )(implicit ctx : Context ): Context =
1086
- ctx.fresh.setProperty(InlinedCalls , call :: enclosingInlineds)
1087
-
1088
- /** All enclosing calls that are currently inlined, from innermost to outermost.
1089
- * EmptyTree calls cancel the next-enclosing non-empty call in the list
1090
- */
1091
- def enclosingInlineds (implicit ctx : Context ): List [Tree ] = {
1092
- def normalize (ts : List [Tree ]): List [Tree ] = ts match {
1093
- case t :: (ts1 @ (t1 :: ts2)) if t.isEmpty => normalize(if (t1.isEmpty) ts1 else ts2)
1094
- case t :: ts1 => t :: normalize(ts1)
1095
- case Nil => Nil
1085
+ /** Record an enclosing inlined call.
1086
+ * EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it.
1087
+ * We assume parameters are never nested inside parameters.
1088
+ */
1089
+ override def inlineContext (call : Tree )(implicit ctx : Context ): Context = {
1090
+ // We assume enclosingInlineds is already normalized, and only process the new call with the head.
1091
+ val oldIC = enclosingInlineds
1092
+ val newIC = (call, oldIC) match {
1093
+ case (t, t1 :: ts2) if t.isEmpty =>
1094
+ assert(! t1.isEmpty)
1095
+ ts2
1096
+ case _ => call :: oldIC
1096
1097
}
1097
- normalize( ctx.property( InlinedCalls ).getOrElse( Nil ) )
1098
+ ctx.fresh.setProperty( InlinedCalls , newIC )
1098
1099
}
1099
1100
1101
+ /** All enclosing calls that are currently inlined, from innermost to outermost.
1102
+ */
1103
+ def enclosingInlineds (implicit ctx : Context ): List [Tree ] =
1104
+ ctx.property(InlinedCalls ).getOrElse(Nil )
1105
+
1100
1106
/** The source file where the symbol of the `inline` method referred to by `call`
1101
1107
* is defined
1102
1108
*/
0 commit comments