Skip to content

Commit

Permalink
Remove @volatile on calls of val
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherMedo committed Jan 16, 2024
1 parent 6653de5 commit 9b5f5e5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/io/ZipArchive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ final class FileZipArchive(jpath: JPath, release: Option[String]) extends ZipArc
override def sizeOption: Option[Int] = Some(zipEntry.getSize.toInt)
}

@volatile lazy val (root, allDirs): (DirEntry, collection.Map[String, DirEntry]) = {
lazy val (root, allDirs): (DirEntry, collection.Map[String, DirEntry]) = {
val root = new DirEntry("/", null)
val dirs = mutable.HashMap[String, DirEntry]("/" -> root)
val zipFile = openZipFile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object AutoParamTupling {
* In order to get thread safety, you need to put @volatile before lazy vals.
* https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals.html
*/
@volatile lazy val xs: List[String] = List("d", "o", "t", "t", "y")
lazy val xs: List[String] = List("d", "o", "t", "t", "y")

/**
* Current behaviour in Scala 2.12.2 :
Expand Down
6 changes: 3 additions & 3 deletions tests/warn/i19416.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- [E193] Syntax Warning: tests\warn\i19416.scala:2:18 -----------------------------------------------------------------
2 | @volatile val x: Int = ??? //warn
| ^
-- [E193] Syntax Warning: tests\warn\i19416.scala:2:18 -----------------------------------------------------------------
2 | @volatile val x: Int = ??? //warn
| ^
| values cannot be volatile

0 comments on commit 9b5f5e5

Please sign in to comment.