diff options
author | Paul Phillips <paulp@improving.org> | 2011-08-06 14:24:42 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-08-06 14:24:42 +0000 |
commit | 4f4a80ad5b85ce3922c80bbc9524f2540918187e (patch) | |
tree | d56b411659069b7bcf841804875545ed0f8925da /src/compiler/scala/tools/nsc/CompilationUnits.scala | |
parent | 6d45fddd4c6537fb343e901d58491b81475e3786 (diff) | |
download | scala-4f4a80ad5b85ce3922c80bbc9524f2540918187e.tar.gz scala-4f4a80ad5b85ce3922c80bbc9524f2540918187e.tar.bz2 scala-4f4a80ad5b85ce3922c80bbc9524f2540918187e.zip |
Don't want to chase NPEs around for the rest of...
Don't want to chase NPEs around for the rest of my life. Created
"NoCompilationUnit" and "NoSourceFile" objects to represent not-present
versions of these items. Seems a lot better than null. References
SI-4859, got past NPE only to uncover the actual problem. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/CompilationUnits.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/CompilationUnits.scala | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala index aba17ca290..f5e32fbb09 100644 --- a/src/compiler/scala/tools/nsc/CompilationUnits.scala +++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala @@ -5,12 +5,20 @@ package scala.tools.nsc -import util.{ FreshNameCreator,Position,NoPosition,SourceFile } +import util.{ FreshNameCreator, Position, NoPosition, SourceFile, NoSourceFile } import scala.collection.mutable import scala.collection.mutable.{ LinkedHashSet, ListBuffer } trait CompilationUnits { self: Global => + /** An object representing a missing compilation unit. + */ + object NoCompilationUnit extends CompilationUnit(NoSourceFile) { + override lazy val isJava = false + override def exists = false + override def toString() = "NoCompilationUnit" + } + /** One unit of compilation that has been submitted to the compiler. * It typically corresponds to a single file of source code. It includes * error-reporting hooks. */ @@ -25,6 +33,8 @@ trait CompilationUnits { self: Global => /** the content of the compilation unit in tree form */ var body: Tree = EmptyTree + def exists = source != NoSourceFile && source != null + // def parseSettings() = { // val argsmarker = "SCALAC_ARGS" // if(comments nonEmpty) { |