-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace (Typing)Transformer with simple Traverser to avoid unnecessar…
…y tree copying
- Loading branch information
Showing
3 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/scala/com/softwaremill/guardedblocks/components/BlockTreesGuardian.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.softwaremill.guardedblocks.components | ||
|
||
import scala.tools.nsc.Global | ||
|
||
class BlockTreesGuardian[G <: Global](val global: G) { | ||
import global._ | ||
|
||
val guard: Tree => Unit = BlockTreesGuardianTraverser.traverse | ||
|
||
private object BlockTreesGuardianTraverser extends Traverser { | ||
override def traverse(tree: Tree): Unit = { | ||
tree match { | ||
case block@Block(stats, expr) => | ||
for { | ||
stat <- stats.filter(_.tpe <:< block.tpe) | ||
} global.reporter.error(stat.pos, s"Found unused statement!") | ||
case _ => | ||
} | ||
super.traverse(tree) | ||
} | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters