@@ -31,7 +31,7 @@ object Inliner {
31
31
32
32
private val InlinedBody = new Property .Key [InlinedBody ] // to be used as attachment
33
33
34
- val InlinedCall = new Property .Key [tpd.Inlined ] // to be used in context
34
+ private val InlinedCall = new Property .Key [List [ tpd.Inlined ] ] // to be used in context
35
35
36
36
def attachBody (inlineAnnot : Annotation , tree : => Tree )(implicit ctx : Context ): Unit =
37
37
inlineAnnot.tree.putAttachment(InlinedBody , new InlinedBody (tree))
@@ -72,12 +72,10 @@ object Inliner {
72
72
}
73
73
74
74
def inlineCall (tree : Tree , pt : Type )(implicit ctx : Context ): Tree = {
75
- if (ctx.inlineCount < ctx.settings.xmaxInlines.value) {
76
- ctx.inlineCount += 1
75
+ if (enclosingInlineds.length < ctx.settings.xmaxInlines.value) {
77
76
val rhs = inlinedBody(tree.symbol)
78
77
val inlined = new Inliner (tree, rhs).inlined
79
- try new Typer ().typedUnadapted(inlined, pt)
80
- finally ctx.inlineCount -= 1
78
+ new Typer ().typedUnadapted(inlined, pt)
81
79
} else errorTree(tree,
82
80
i """ Maximal number of successive inlines ( ${ctx.settings.xmaxInlines.value}) exceeded,
83
81
| Maybe this is caused by a recursive inline method?
@@ -93,17 +91,10 @@ object Inliner {
93
91
}
94
92
95
93
def inlineContext (tree : untpd.Inlined )(implicit ctx : Context ): Context =
96
- ctx.fresh.setProperty(InlinedCall , tree)
97
-
98
- def enclosingInlineds (implicit ctx : Context ): Stream [Inlined ] =
99
- ctx.property(InlinedCall ) match {
100
- case found @ Some (inlined) =>
101
- inlined #::
102
- enclosingInlineds(
103
- ctx.outersIterator.dropWhile(_.property(InlinedCall ) == found).next)
104
- case _ =>
105
- Stream .Empty
106
- }
94
+ ctx.fresh.setProperty(InlinedCall , tree :: enclosingInlineds)
95
+
96
+ def enclosingInlineds (implicit ctx : Context ): List [Inlined ] =
97
+ ctx.property(InlinedCall ).getOrElse(Nil )
107
98
108
99
def sourceFile (inlined : Inlined )(implicit ctx : Context ) = {
109
100
val file = inlined.call.symbol.sourceFile
0 commit comments