summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-11-04 18:25:19 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-11-04 18:25:19 +0000
commita4895b85928399db4ed8d744ac3fc7208bee3a2f (patch)
treed35b8e593c23ca9532c2e90a87e04166132f5f40 /src/compiler/scala/tools
parentdbf0e12c15a0c0f3ac8833ecf70d0228ab0f1c3e (diff)
downloadscala-a4895b85928399db4ed8d744ac3fc7208bee3a2f.tar.gz
scala-a4895b85928399db4ed8d744ac3fc7208bee3a2f.tar.bz2
scala-a4895b85928399db4ed8d744ac3fc7208bee3a2f.zip
fix cyclic reference errors in scaladoc.
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala24
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala4
3 files changed, 33 insertions, 9 deletions
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() {
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index 836d23760d..e128b4e12f 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -336,16 +336,16 @@ abstract class TreeInfo {
/** Compilation unit is the predef object
*/
- def isPredefUnit(tree: Tree): Boolean = tree match {
- case PackageDef(Ident(nme.scala_), defs) => isPredefObj(defs)
+ def isUnitInScala(tree: Tree, name: Name) = tree match {
+ case PackageDef(Ident(nme.scala_), defs) => isObject(defs, name)
case _ => false
}
- private def isPredefObj(trees: List[Tree]): Boolean = trees match {
- case Import(_, _) :: xs => isPredefObj(xs)
- case ModuleDef(_, nme.Predef, _) :: Nil => true
- case DocDef(_, tree1) :: Nil => isPredefObj(List(tree1))
- case Annotated(_, tree1) :: Nil => isPredefObj(List(tree1))
+ private def isObject(trees: List[Tree], name: Name): Boolean = trees match {
+ case Import(_, _) :: xs => isObject(xs, name)
+ case DocDef(_, tree1) :: Nil => isObject(List(tree1), name)
+ case Annotated(_, tree1) :: Nil => isObject(List(tree1), name)
+ case ModuleDef(_, `name`, _) :: Nil => true
case _ => false
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index cc8b069607..2be187381f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -46,7 +46,9 @@ trait Contexts { self: Analyzer =>
if (!unit.isJava) {
assert(ScalaPackage ne null, "Scala package is null")
imps += ScalaPackage
- if (!(treeInfo.isPredefUnit(unit.body) || treeInfo.containsLeadingPredefImport(List(unit.body))))
+ if (!(treeInfo.isUnitInScala(unit.body, nme.Predef) ||
+ treeInfo.isUnitInScala(unit.body, nme.ScalaObject) ||
+ treeInfo.containsLeadingPredefImport(List(unit.body))))
imps += PredefModule
}
}