diff options
Diffstat (limited to 'src/compiler')
4 files changed, 16 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index ee03aa1ac2..d1d5cd1f03 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -85,7 +85,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) lazy val platform: ThisPlatform = new { val global: Global.this.type = Global.this } with JavaPlatform - type PlatformClassPath = ClassPath[platform.BinaryRepr] + type PlatformClassPath = ClassPath[AbstractFile] type OptClassPath = Option[PlatformClassPath] def classPath: PlatformClassPath = platform.classPath @@ -924,7 +924,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) invalidated: mutable.ListBuffer[ClassSymbol], failed: mutable.ListBuffer[ClassSymbol]) { ifDebug(informProgress(s"syncing $root, $oldEntries -> $newEntries")) - val getName: ClassPath[platform.BinaryRepr] => String = (_.name) + val getName: ClassPath[AbstractFile] => String = (_.name) def hasClasses(cp: OptClassPath) = cp.isDefined && cp.get.classes.nonEmpty def invalidateOrRemove(root: ClassSymbol) = { allEntries match { diff --git a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala index c5fc12e3ec..780bc81bcc 100644 --- a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala +++ b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala @@ -14,29 +14,18 @@ trait JavaPlatform extends Platform { import global._ import definitions._ - type BinaryRepr = AbstractFile + private var currentClassPath: Option[MergedClassPath[AbstractFile]] = None - private var currentClassPath: Option[MergedClassPath[BinaryRepr]] = None - - def classPath: ClassPath[BinaryRepr] = { + def classPath: ClassPath[AbstractFile] = { if (currentClassPath.isEmpty) currentClassPath = Some(new PathResolver(settings).result) currentClassPath.get } /** Update classpath with a substituted subentry */ - def updateClassPath(subst: Map[ClassPath[BinaryRepr], ClassPath[BinaryRepr]]) = + def updateClassPath(subst: Map[ClassPath[AbstractFile], ClassPath[AbstractFile]]) = currentClassPath = Some(new DeltaClassPath(currentClassPath.get, subst)) - def rootLoader = new loaders.PackageLoader(classPath.asInstanceOf[ClassPath[platform.BinaryRepr]]) - // [Martin] Why do we need a cast here? - // The problem is that we cannot specify at this point that global.platform should be of type JavaPlatform. - // So we cannot infer that global.platform.BinaryRepr is AbstractFile. - // Ideally, we should be able to write at the top of the JavaPlatform trait: - // val global: Global { val platform: JavaPlatform } - // import global._ - // Right now, this does nothing because the concrete definition of platform in Global - // replaces the tighter abstract definition here. If we had DOT typing rules, the two - // types would be conjoined and everything would work out. Yet another reason to push for DOT. + def rootLoader = new loaders.PackageLoader(classPath) private def classEmitPhase = if (settings.isBCodeActive) genBCode @@ -69,7 +58,7 @@ trait JavaPlatform extends Platform { def newClassLoader(bin: AbstractFile): loaders.SymbolLoader = new loaders.ClassfileLoader(bin) - def doLoad(cls: ClassPath[BinaryRepr]#ClassRep): Boolean = true + def doLoad(cls: ClassPath[AbstractFile]#ClassRep): Boolean = true def needCompile(bin: AbstractFile, src: AbstractFile) = src.lastModified >= bin.lastModified diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala index e2b22c06d7..25a6e6f36a 100644 --- a/src/compiler/scala/tools/nsc/backend/Platform.scala +++ b/src/compiler/scala/tools/nsc/backend/Platform.scala @@ -16,16 +16,17 @@ trait Platform { import global._ /** The binary classfile representation type */ - type BinaryRepr + @deprecated("BinaryRepr is not an abstract type anymore. It's an alias that points at AbstractFile. It'll be removed before Scala 2.11 is released.", "2.11.0-M5") + type BinaryRepr = AbstractFile /** The compiler classpath. */ - def classPath: ClassPath[BinaryRepr] + def classPath: ClassPath[AbstractFile] /** The root symbol loader. */ def rootLoader: LazyType /** Update classpath with a substitution that maps entries to entries */ - def updateClassPath(subst: Map[ClassPath[BinaryRepr], ClassPath[BinaryRepr]]) + def updateClassPath(subst: Map[ClassPath[AbstractFile], ClassPath[AbstractFile]]) /** Any platform-specific phases. */ def platformPhases: List[SubComponent] @@ -37,7 +38,7 @@ trait Platform { def isMaybeBoxed(sym: Symbol): Boolean /** Create a new class loader to load class file `bin` */ - def newClassLoader(bin: BinaryRepr): loaders.SymbolLoader + def newClassLoader(bin: AbstractFile): loaders.SymbolLoader /** * Tells whether a class should be loaded and entered into the package @@ -45,7 +46,7 @@ trait Platform { * (anonymous classes, implementation classes, module classes), their * symtab is encoded in the pickle of another class. */ - def doLoad(cls: ClassPath[BinaryRepr]#ClassRep): Boolean + def doLoad(cls: ClassPath[AbstractFile]#ClassRep): Boolean /** * Tells whether a class with both a binary and a source representation @@ -53,6 +54,6 @@ trait Platform { * on the JVM similar to javac, i.e. if the source file is newer than the classfile, * a re-compile is triggered. On .NET by contrast classfiles always take precedence. */ - def needCompile(bin: BinaryRepr, src: AbstractFile): Boolean + def needCompile(bin: AbstractFile, src: AbstractFile): Boolean } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index ac38e24787..201a2315ab 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -144,7 +144,7 @@ abstract class SymbolLoaders { /** Initialize toplevel class and module symbols in `owner` from class path representation `classRep` */ - def initializeFromClassPath(owner: Symbol, classRep: ClassPath[platform.BinaryRepr]#ClassRep) { + def initializeFromClassPath(owner: Symbol, classRep: ClassPath[AbstractFile]#ClassRep) { ((classRep.binary, classRep.source) : @unchecked) match { case (Some(bin), Some(src)) if platform.needCompile(bin, src) && !binaryOnly(owner, classRep.name) => @@ -226,7 +226,7 @@ abstract class SymbolLoaders { /** * Load contents of a package */ - class PackageLoader(classpath: ClassPath[platform.BinaryRepr]) extends SymbolLoader with FlagAgnosticCompleter { + class PackageLoader(classpath: ClassPath[AbstractFile]) extends SymbolLoader with FlagAgnosticCompleter { protected def description = "package loader "+ classpath.name protected def doComplete(root: Symbol) { |