diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-24 14:12:25 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-24 14:14:03 -0800 |
commit | 856d4e403c63c4ddb5d30f2cb7213e059eafb1e4 (patch) | |
tree | 4444a42ee3e2c004a9ec7c31ddcad4bd0af58ee2 /src | |
parent | 05e302de53ff42bf2602b66efd97c9058e5e9fad (diff) | |
download | scala-856d4e403c63c4ddb5d30f2cb7213e059eafb1e4.tar.gz scala-856d4e403c63c4ddb5d30f2cb7213e059eafb1e4.tar.bz2 scala-856d4e403c63c4ddb5d30f2cb7213e059eafb1e4.zip |
Created NoAbstractFile.
A very distinguished value in case one feels (as this one does)
that null is disheartening and Option only marginally better.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/MsilFile.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/NoAbstractFile.scala | 30 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/io/MsilFile.scala b/src/compiler/scala/tools/nsc/io/MsilFile.scala index 69db23923d..d970d0e9c9 100644 --- a/src/compiler/scala/tools/nsc/io/MsilFile.scala +++ b/src/compiler/scala/tools/nsc/io/MsilFile.scala @@ -13,4 +13,6 @@ import ch.epfl.lamp.compiler.msil.{ Type => MsilType, _ } * uniformly, as AbstractFiles. */ class MsilFile(val msilType: MsilType) extends VirtualFile(msilType.FullName, msilType.Namespace) { -}
\ No newline at end of file +} + +object NoMsilFile extends MsilFile(null) { } diff --git a/src/compiler/scala/tools/nsc/io/NoAbstractFile.scala b/src/compiler/scala/tools/nsc/io/NoAbstractFile.scala new file mode 100644 index 0000000000..36cf42d7ec --- /dev/null +++ b/src/compiler/scala/tools/nsc/io/NoAbstractFile.scala @@ -0,0 +1,30 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2011 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package io + +import java.io.InputStream + +/** A distinguished object so you can avoid both null + * and Option. + */ +object NoAbstractFile extends AbstractFile { + def absolute: AbstractFile = this + def container: AbstractFile = this + def create(): Unit = ??? + def delete(): Unit = ??? + def file: JFile = null + def input: InputStream = null + def isDirectory: Boolean = false + def iterator: Iterator[AbstractFile] = Iterator.empty + def lastModified: Long = 0L + def lookupName(name: String, directory: Boolean): AbstractFile = null + def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = null + def name: String = "" + def output: java.io.OutputStream = null + def path: String = "" + override def toByteArray = Array[Byte]() +} |