Skip to content

Commit 55b22b1

Browse files
committed
Rewrite io files to compile under Dotty
1 parent 29b3ee0 commit 55b22b1

9 files changed

+21
-422
lines changed

compiler/src/dotty/tools/dotc/util/WeakHashSet.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ final class WeakHashSet[A >: Null <: AnyRef](val initialCapacity: Int, val loadF
8686
/**
8787
* remove a single entry from a linked list in a given bucket
8888
*/
89-
private[this] def remove(bucket: Int, prevEntry: Entry[A], entry: Entry[A]) {
89+
private[this] def remove(bucket: Int, prevEntry: Entry[A], entry: Entry[A]): Unit = {
9090
prevEntry match {
9191
case null => table(bucket) = entry.tail
9292
case _ => prevEntry.tail = entry.tail
@@ -97,7 +97,7 @@ final class WeakHashSet[A >: Null <: AnyRef](val initialCapacity: Int, val loadF
9797
/**
9898
* remove entries associated with elements that have been gc'ed
9999
*/
100-
private[this] def removeStaleEntries() {
100+
private[this] def removeStaleEntries(): Unit = {
101101
def poll(): Entry[A] = queue.poll().asInstanceOf[Entry[A]]
102102

103103
@tailrec
@@ -122,7 +122,7 @@ final class WeakHashSet[A >: Null <: AnyRef](val initialCapacity: Int, val loadF
122122
/**
123123
* Double the size of the internal table
124124
*/
125-
private[this] def resize() {
125+
private[this] def resize(): Unit = {
126126
val oldTable = table
127127
table = new Array[Entry[A]](oldTable.size * 2)
128128
threshhold = computeThreshHold
@@ -207,7 +207,7 @@ final class WeakHashSet[A >: Null <: AnyRef](val initialCapacity: Int, val loadF
207207
val bucket = bucketFor(hash)
208208
val oldHead = table(bucket)
209209

210-
def add() {
210+
def add() = {
211211
table(bucket) = new Entry(elem, hash, oldHead, queue)
212212
count += 1
213213
if (count > threshhold) resize()
@@ -228,7 +228,7 @@ final class WeakHashSet[A >: Null <: AnyRef](val initialCapacity: Int, val loadF
228228
def +=(elem: A) = this + elem
229229

230230
// from scala.reflect.interanl.Set
231-
override def addEntry(x: A) { this += x }
231+
override def addEntry(x: A) = { this += x }
232232

233233
// remove an element from this set and return this set
234234
override def -(elem: A): this.type = elem match {

compiler/src/dotty/tools/io/AbstractFile.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ abstract class AbstractFile extends Iterable[AbstractFile] {
114114

115115
/** Does this abstract file denote an existing file? */
116116
def exists: Boolean = {
117-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileExistsCount)
118117
(file eq null) || file.exists
119118
}
120119

compiler/src/dotty/tools/io/IOStats.scala

Lines changed: 0 additions & 29 deletions
This file was deleted.

compiler/src/dotty/tools/io/Path.scala

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,8 @@ object Path {
5454

5555
def apply(path: String): Path = apply(new JFile(path))
5656
def apply(jfile: JFile): Path = try {
57-
def isFile = {
58-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileIsFileCount)
59-
jfile.isFile
60-
}
61-
62-
def isDirectory = {
63-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileIsDirectoryCount)
64-
jfile.isDirectory
65-
}
66-
67-
if (isFile) new File(jfile)
68-
else if (isDirectory) new Directory(jfile)
57+
if (jfile.isFile) new File(jfile)
58+
else if (jfile.isDirectory) new Directory(jfile)
6959
else new Path(jfile)
7060
} catch { case ex: SecurityException => new Path(jfile) }
7161

@@ -195,19 +185,11 @@ class Path private[io] (val jfile: JFile) {
195185
// Boolean tests
196186
def canRead = jfile.canRead()
197187
def canWrite = jfile.canWrite()
198-
def exists = {
199-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileExistsCount)
200-
try jfile.exists() catch { case ex: SecurityException => false }
201-
}
202-
203-
def isFile = {
204-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileIsFileCount)
205-
try jfile.isFile() catch { case ex: SecurityException => false }
206-
}
207-
def isDirectory = {
208-
if (Statistics.canEnable) Statistics.incCounter(IOStats.fileIsDirectoryCount)
209-
try jfile.isDirectory() catch { case ex: SecurityException => jfile.getPath == "." }
210-
}
188+
def exists = try jfile.exists() catch { case ex: SecurityException => false }
189+
def isFile = try jfile.isFile() catch { case ex: SecurityException => false }
190+
def isDirectory =
191+
try jfile.isDirectory()
192+
catch { case ex: SecurityException => jfile.getPath == "." }
211193
def isAbsolute = jfile.isAbsolute()
212194
def isEmpty = path.length == 0
213195

0 commit comments

Comments
 (0)