File tree Expand file tree Collapse file tree 4 files changed +13
-14
lines changed
test/dotty/tools/backend/jvm Expand file tree Collapse file tree 4 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -847,17 +847,18 @@ object Erasure {
847847 override def typedTry (tree : untpd.Try , pt : Type )(using Context ): Try =
848848 super .typedTry(tree, adaptProto(tree, pt))
849849
850+ override def typedBlock (tree : untpd.Block , pt : Type )(using Context ): Tree =
851+ super .typedBlock(tree, pt) match
852+ // Drop empty block after it has been repositioned (see Inliner.reposition)
853+ case Block (Nil , expr) => expr
854+ case block => block
855+
850856 private def adaptProto (tree : untpd.Tree , pt : Type )(using Context ) =
851857 if (pt.isValueType) pt else
852858 if (tree.typeOpt.derivesFrom(ctx.definitions.UnitClass ))
853859 tree.typeOpt
854860 else valueErasure(tree.typeOpt)
855861
856- override def typedInlined (tree : untpd.Inlined , pt : Type )(using Context ): Tree =
857- super .typedInlined(tree, pt) match {
858- case tree : Inlined => Inliner .dropInlined(tree)
859- }
860-
861862 override def typedValDef (vdef : untpd.ValDef , sym : Symbol )(using Context ): Tree =
862863 if (sym.isEffectivelyErased) erasedDef(sym)
863864 else
Original file line number Diff line number Diff line change @@ -214,6 +214,9 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
214214 case _ => tree
215215 }
216216
217+ override def transformInlined (tree : Inlined )(using Context ): Tree =
218+ cpy.Block (tree)(tree.bindings, tree.expansion)
219+
217220 // invariants: all modules have companion objects
218221 // all types are TypeTrees
219222 // all this types are explicit
Original file line number Diff line number Diff line change @@ -205,11 +205,6 @@ object Inliner {
205205 using ctx.withOwner(retainer)))
206206 .reporting(i " retainer for $meth: $result" , inlining)
207207
208- /** Replace `Inlined` node by a block that contains its bindings and expansion */
209- def dropInlined (inlined : Inlined )(using Context ): Tree =
210- if inlined.bindings.isEmpty then inlined.expansion
211- else cpy.Block (inlined)(inlined.bindings, inlined.expansion)
212-
213208 def reposition (tree : Tree , callSpan : Span )(using Context ): Tree = {
214209 // Reference test tests/run/i4947b
215210
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ class InlineBytecodeTests extends DottyBytecodeTest {
134134 val expected =
135135 List (
136136 Label (0 ),
137- LineNumber (6 , Label (0 )),
137+ LineNumber (2 , Label (0 )), // TODO this lable seems to not be used
138138 LineNumber (3 , Label (0 )),
139139 VarOp (ALOAD , 0 ),
140140 Ldc (LDC , " tracking" ),
@@ -199,7 +199,7 @@ class InlineBytecodeTests extends DottyBytecodeTest {
199199 val expected =
200200 List (
201201 Label (0 ),
202- LineNumber (12 , Label (0 )),
202+ LineNumber (6 , Label (0 )), // TODO this lable seems to not be used
203203 LineNumber (7 , Label (0 )),
204204 VarOp (ALOAD , 0 ),
205205 Ldc (LDC , " tracking" ),
@@ -259,7 +259,7 @@ class InlineBytecodeTests extends DottyBytecodeTest {
259259 val expected =
260260 List (
261261 Label (0 ),
262- LineNumber (12 , Label (0 )),
262+ LineNumber (2 , Label (0 )), // TODO this lable seems to not be used
263263 LineNumber (3 , Label (0 )),
264264 VarOp (ALOAD , 0 ),
265265 Ldc (LDC , " tracking2" ),
@@ -320,7 +320,7 @@ class InlineBytecodeTests extends DottyBytecodeTest {
320320 val expected =
321321 List (
322322 Label (0 ),
323- LineNumber (13 , Label (0 )),
323+ LineNumber (2 , Label (0 )), // TODO this lable seems to not be used
324324 LineNumber (3 , Label (0 )),
325325 VarOp (ALOAD , 0 ),
326326 Ldc (LDC , " tracking2" ),
You can’t perform that action at this time.
0 commit comments