@@ -361,22 +361,16 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
361
361
}
362
362
363
363
object IsBlock extends IsBlockModule {
364
- def unapply (x : Term )(implicit ctx : Context ): Option [Block ] = Block . normalizedLoops(x) match {
364
+ def unapply (x : Term )(implicit ctx : Context ): Option [Block ] = normalizedLoops(x) match {
365
365
case x : tpd.Block => Some (x)
366
366
case _ => None
367
367
}
368
- }
369
368
370
- object Block extends BlockExtractor {
371
- def unapply (x : Term )(implicit ctx : Context ): Option [(List [Statement ], Term )] = normalizedLoops(x) match {
372
- case Trees .Block (stats, expr) => Some ((stats, expr))
373
- case _ => None
374
- }
375
369
/** Normalizes non Blocks.
376
370
* i) Put `while` and `doWhile` loops in their own blocks: `{ def while$() = ...; while$() }`
377
371
* ii) Put closures in their own blocks: `{ def anon$() = ...; closure(anon$, ...) }`
378
372
*/
379
- private [ Term ] def normalizedLoops (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
373
+ private def normalizedLoops (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
380
374
case block : tpd.Block if block.stats.size > 1 =>
381
375
def normalizeInnerLoops (stats : List [tpd.Tree ]): List [tpd.Tree ] = stats match {
382
376
case (x : tpd.DefDef ) :: y :: xs if needsNormalization(y) =>
@@ -402,6 +396,13 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
402
396
}
403
397
}
404
398
399
+ object Block extends BlockExtractor {
400
+ def unapply (x : Term )(implicit ctx : Context ): Option [(List [Statement ], Term )] = x match {
401
+ case IsBlock (x) => Some ((x.stats, x.expr))
402
+ case _ => None
403
+ }
404
+ }
405
+
405
406
object IsInlined extends IsInlinedModule {
406
407
def unapply (x : Term )(implicit ctx : Context ): Option [Inlined ] = x match {
407
408
case x : tpd.Inlined => Some (x)
0 commit comments