Compatible with latest 2.8 nightly

This commit is contained in:
Mark Harrah 2009-11-01 21:21:59 -05:00
parent e559ca113f
commit 871b9bbcc2
3 changed files with 46 additions and 14 deletions

View File

@ -47,7 +47,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager)
val start = System.currentTimeMillis
try
{
compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars, outputDirectory, Nil, true)
compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars, outputDirectory, "-nowarn" :: Nil, true)
manager.log.info(" Compilation completed in " + (System.currentTimeMillis - start) / 1000.0 + " s")
}
catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'") }

View File

@ -115,19 +115,18 @@ final class Analyzer(val global: Global, val callback: AnalysisCallback) extends
{
import scala.tools.nsc.symtab.Flags
val name = sym.fullNameString(File.separatorChar) + (if (sym.hasFlag(Flags.MODULE)) "$" else "")
val entry = classPath.root.find(name, false)
if (entry ne null)
Some(entry.classFile)
else if(isTopLevelModule(sym))
{
val linked = sym.linkedClassOfModule
if(linked == NoSymbol)
None
finder.findClass(name) orElse {
if(isTopLevelModule(sym))
{
val linked = sym.linkedClassOfModule
if(linked == NoSymbol)
None
else
classFile(linked)
}
else
classFile(linked)
None
}
else
None
}
private def isTopLevelModule(sym: Symbol): Boolean =
@ -178,4 +177,37 @@ final class Analyzer(val global: Global, val callback: AnalysisCallback) extends
private def isStringArray(tpe: Type): Boolean = tpe =:= StringArrayType
private def isStringArray(sym: Symbol): Boolean = isStringArray(sym.tpe)
private def isUnitType(tpe: Type) = tpe.typeSymbol == definitions.UnitClass
// required because the 2.8 way to find a class is:
// classPath.findClass(name).flatMap(_.binary)
// and the 2.7 way is:
// val entry = classPath.root.find(name, false)
// if(entry eq null) None else Some(entry.classFile)
private lazy val finder = try { new LegacyFinder } catch { case _ => new NewFinder }
private trait ClassFinder
{
def findClass(name: String): Option[AbstractFile]
}
private class NewFinder extends ClassFinder
{
def findClass(name: String): Option[AbstractFile] =
call[Option[AnyRef]](classPath, "findClass", classOf[String])(name).flatMap(extractClass)
private def extractClass(a: AnyRef) =
call[Option[AbstractFile]](a, "binary")()
}
private class LegacyFinder extends ClassFinder
{
private val root = call[AnyRef](classPath, "root")()
def findClass(name: String): Option[AbstractFile] =
{
val entry = call[Option[AnyRef]](root, "find", classOf[String], classOf[Boolean])(name, boolean2Boolean(false))
if (entry eq null)
None
else
Some( call[AbstractFile](entry, "classFile")() )
}
}
import scala.reflect.Manifest
private def call[T <: AnyRef](on: AnyRef, name: String, tpes: Class[_]*)(args: AnyRef*)(implicit mf: Manifest[T]): T =
mf.erasure.cast(on.getClass.getMethod(name, tpes : _*).invoke(on, args : _*)).asInstanceOf[T]
}

View File

@ -1,7 +1,7 @@
#Project properties
#Mon Oct 19 11:03:16 EDT 2009
#Sat Oct 31 19:01:55 EDT 2009
project.organization=org.scala-tools.sbt
project.name=xsbt
sbt.version=0.5.6-p2
project.version=0.6.0
project.version=0.6.1
scala.version=2.7.5