Skip to content

Commit

Permalink
Merge pull request #15 from scalacenter/private-lazy-val
Browse files Browse the repository at this point in the history
Fix bug for lazy vals with other modifiers
  • Loading branch information
olafurpg authored Oct 20, 2016
2 parents 2b0d358 + c947bde commit 4479aaf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/scalafix/rewrite/VolatileLazyVal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ case object VolatileLazyVal extends Rewrite {
case x if x.syntax == "@volatile" =>
None
case x if x.syntax == "lazy" =>
Some(x.tokens.head)
Some(defn.mods.head.tokens.head)
}
}.flatten
}
override def rewrite(ast: Tree, ctx: RewriteCtx): Seq[Patch] = {
ast.collect {
case NonVolatileLazyVal(tok) => Patch(tok, tok, "@volatile lazy")
case NonVolatileLazyVal(tok) => Patch(tok, tok, s"@volatile ${tok.syntax}")
}
}
}
2 changes: 2 additions & 0 deletions core/src/test/scala/scalafix/rewrite/LazyValSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LazyValSuite extends RewriteSuite(VolatileLazyVal) {
|
| lazy val x = 2
| @volatile lazy val dontChangeMe = 2
| private lazy val x = 2
|
| class foo {
| lazy val z = {
Expand All @@ -26,6 +27,7 @@ class LazyValSuite extends RewriteSuite(VolatileLazyVal) {
|
| @volatile lazy val x = 2
| @volatile lazy val dontChangeMe = 2
| @volatile private lazy val x = 2
|
| class foo {
| @volatile lazy val z = {
Expand Down

0 comments on commit 4479aaf

Please sign in to comment.