diff options
author | Martin Odersky <odersky@gmail.com> | 2012-07-26 16:03:47 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-07-26 16:03:47 +0200 |
commit | 54bab793ae6fbe3219efa8ef2e6a0015bbab7666 (patch) | |
tree | a865e801db829846de5235484628f0c44fd7da04 /src/compiler | |
parent | ad08f24448729009fc8d5ff0acf307a43b4cfe0a (diff) | |
download | scala-54bab793ae6fbe3219efa8ef2e6a0015bbab7666.tar.gz scala-54bab793ae6fbe3219efa8ef2e6a0015bbab7666.tar.bz2 scala-54bab793ae6fbe3219efa8ef2e6a0015bbab7666.zip |
Avoids loading scala.package and scala.reflect.package from source if a classfile exists.
We know that loading these packages from source leads to compilation errors. To reproduce: Update scala.reflect.package, make sure it is on the source path and recompile anything using it. You will get a number of errors having to do with ClassTags and macro expansions. With the patch, these errors go away because the package is not loaded as long as a classfile exists.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 9b4e793241..46c52e68a2 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -112,11 +112,23 @@ abstract class SymbolLoaders { enterClassAndModule(root, name, new SourcefileLoader(src)) } + /** The package objects of scala and scala.reflect should always + * be loaded in binary if classfiles are available, even if sourcefiles + * are newer. Late-compiling these objects from source leads to compilation + * order issues. + * Note: We do a name-base comparison here because the method is called before we even + * have ReflectPackage defined. + */ + def binaryOnly(owner: Symbol, name: String): Boolean = + name == "package" && + (owner.fullName == "scala" || owner.fullName == "scala.reflect") + /** Initialize toplevel class and module symbols in `owner` from class path representation `classRep` */ def initializeFromClassPath(owner: Symbol, classRep: ClassPath[platform.BinaryRepr]#ClassRep) { ((classRep.binary, classRep.source) : @unchecked) match { - case (Some(bin), Some(src)) if platform.needCompile(bin, src) => + case (Some(bin), Some(src)) + if platform.needCompile(bin, src) && !binaryOnly(owner, classRep.name) => if (settings.verbose.value) inform("[symloader] picked up newer source file for " + src.path) global.loaders.enterToplevelsFromSource(owner, classRep.name, src) case (None, Some(src)) => |