From a4895b85928399db4ed8d744ac3fc7208bee3a2f Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 4 Nov 2009 18:25:19 +0000 Subject: fix cyclic reference errors in scaladoc. --- src/compiler/scala/tools/nsc/Global.scala | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/compiler/scala/tools/nsc/Global.scala') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 8c8d0be322..191016e133 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -777,7 +777,8 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable /** Compile list of source files */ def compileSources(_sources: List[SourceFile]) { - val sources = dependencyAnalysis.filter(_sources.removeDuplicates) // bug #1268, scalac confused by duplicated filenames + val depSources = dependencyAnalysis.filter(_sources.removeDuplicates) // bug #1268, scalac confused by duplicated filenames + val sources = pkgObjectsFirst(depSources) if (reporter.hasErrors) return // there is a problem already, e.g. a // plugin was passed a bad option @@ -921,6 +922,27 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable } if (!pclazz.isRoot) resetPackageClass(pclazz.owner) } + + private def pkgObjectsFirst(files: List[SourceFile]) = { + def inScalaFolder(f: SourceFile) = + f.file.container.name == "scala" + val res = new ListBuffer[SourceFile] + var scalaObject: Option[SourceFile] = None + var lowPriorityImplicits: Option[SourceFile] = None + var predef: Option[SourceFile] = None + for (file <- files) file.file.name match { + case "ScalaObject.scala" if inScalaFolder(file) => scalaObject = Some(file) + case "LowPriorityImplicits.scala" if inScalaFolder(file) => lowPriorityImplicits = Some(file) + case "Predef.scala" if inScalaFolder(file) => predef = Some(file) + case "package.scala" => file +=: res // prepend package objects + case _ => res += file // append all others + } + val f: SourceFile => Unit = res.+=:(_) + predef map f // Predef 3rd + lowPriorityImplicits map f // LowPriorityImplicits 2nd + scalaObject map f // ScalaObject 1st + res.toList // then package objects, then others + } } // class Run def printAllUnits() { -- cgit v1.2.3