File tree 1 file changed +14
-12
lines changed
compiler/src/dotty/tools/dotc/typer
1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -151,23 +151,25 @@ object Inliner {
151
151
def dropInlined (inlined : tpd.Inlined )(implicit ctx : Context ): Tree = {
152
152
if (enclosingInlineds.nonEmpty) inlined // remove in the outer inlined call
153
153
else {
154
- val reposition = new TreeMap {
155
- private [this ] var pos : Position = inlined.pos
154
+ class Reposition extends TreeMap {
156
155
override def transform (tree : Tree )(implicit ctx : Context ): Tree = {
157
156
tree match {
158
- case inlined : Inlined =>
159
- val last = pos
160
- pos = inlined.call.pos
161
- val res = tpd.seq(inlined.bindings.map(transform), transform(inlined.expansion)).withPos(last)
162
- pos = last
163
- res
164
- case tree =>
165
- if (pos.exists) super .transform(tree).withPos(pos)
166
- else super .transform(tree)
157
+ case tree : Inlined => transformInline(tree)
158
+ case _ =>
159
+ val transformed = super .transform(tree)
160
+ enclosingInlineds match {
161
+ case call :: _ if ! call.isEmpty =>
162
+ // This tree was inlined and will have the position of the call that was inlined
163
+ transformed.withPos(call.pos)
164
+ case _ => transformed
165
+ }
167
166
}
168
167
}
168
+ def transformInline (tree : tpd.Inlined )(implicit ctx : Context ): Tree = {
169
+ tpd.seq(transformSub(tree.bindings), transform(tree.expansion)(inlineContext(tree.call)))
170
+ }
169
171
}
170
- reposition.transform (inlined)
172
+ ( new Reposition ).transformInline (inlined)
171
173
}
172
174
}
173
175
}
You can’t perform that action at this time.
0 commit comments