summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-07-27 01:38:45 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-07-27 14:09:40 -0700
commitd898ca3eddf032040bbcc2a38ec6ad7813f37cfb (patch)
tree4a39668ec381837c2d98e4d0d3fd7ae3bdf07ed9
parente5121c888239b3a18ea7b341981d41bb4c9a1c07 (diff)
downloadscala-d898ca3eddf032040bbcc2a38ec6ad7813f37cfb.tar.gz
scala-d898ca3eddf032040bbcc2a38ec6ad7813f37cfb.tar.bz2
scala-d898ca3eddf032040bbcc2a38ec6ad7813f37cfb.zip
Deprecate Platform.BinaryRepr.
The 27c8266e introduced `Platform.BinaryRepr` abstract type that was meant to abstract over binary representation of a classfile. The abstraction was needed at the time because we had both jvm backend and msil backend. The msil backend has been removed but the abstraction was kept in place. The type has been deprecated and set to be an alias for AbstractFile. The alias will be removed later in 2.11 milestone cycle. All references to `Platform.BinaryRepr` has been removed in the compiler in favour of using AbstractFile directly. If we ever need to abstract over multiple backends we should do that based on real requirements of given backends. This is a first step towards breaking the cyclic dependency between Platform and SymbolLoaders.
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/JavaPlatform.scala21
-rw-r--r--src/compiler/scala/tools/nsc/backend/Platform.scala13
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala4
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) {