Skip to content

Commit

Permalink
SI-5939 resident compilation of sources in empty package
Browse files Browse the repository at this point in the history
Empty packages can now be cleanly invalidated.
  • Loading branch information
odersky authored and adriaanm committed Jul 19, 2012
1 parent d9b6559 commit 4f3c92e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
21 changes: 11 additions & 10 deletions src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
Expand Up @@ -34,8 +34,7 @@ abstract class SymbolLoaders {
/** Enter class with given `name` into scope of `root`
* and give them `completer` as type.
*/
def enterClass(root: Symbol, name: String, completer: SymbolLoader): Symbol = {
val owner = root.ownerOfNewSymbols
def enterClass(owner: Symbol, name: String, completer: SymbolLoader): Symbol = {
val clazz = owner.newClass(newTypeName(name))
clazz setInfo completer
enterIfNew(owner, clazz, completer)
Expand All @@ -44,8 +43,7 @@ abstract class SymbolLoaders {
/** Enter module with given `name` into scope of `root`
* and give them `completer` as type.
*/
def enterModule(root: Symbol, name: String, completer: SymbolLoader): Symbol = {
val owner = root.ownerOfNewSymbols
def enterModule(owner: Symbol, name: String, completer: SymbolLoader): Symbol = {
val module = owner.newModule(newTermName(name))
module setInfo completer
module.moduleClass setInfo moduleClassLoader
Expand Down Expand Up @@ -217,15 +215,18 @@ abstract class SymbolLoaders {
root.setInfo(new PackageClassInfoType(newScope, root))

val sourcepaths = classpath.sourcepaths
for (classRep <- classpath.classes if platform.doLoad(classRep)) {
initializeFromClassPath(root, classRep)
if (!root.isRoot) {
for (classRep <- classpath.classes if platform.doLoad(classRep)) {
initializeFromClassPath(root, classRep)
}
}
if (!root.isEmptyPackageClass) {
for (pkg <- classpath.packages) {
enterPackage(root, pkg.name, new PackageLoader(pkg))
}

for (pkg <- classpath.packages) {
enterPackage(root, pkg.name, new PackageLoader(pkg))
openPackageModule(root)
}

openPackageModule(root)
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/reflect/scala/reflect/internal/Mirrors.scala
Expand Up @@ -180,7 +180,7 @@ trait Mirrors extends api.Mirrors {
// Still fiddling with whether it's cleaner to do some of this setup here
// or from constructors. The latter approach tends to invite init order issues.

EmptyPackageClass setInfo ClassInfoType(Nil, newPackageScope(EmptyPackageClass), EmptyPackageClass)
EmptyPackageClass setInfo rootLoader
EmptyPackage setInfo EmptyPackageClass.tpe

connectModuleToClass(EmptyPackage, EmptyPackageClass)
Expand Down Expand Up @@ -231,7 +231,6 @@ trait Mirrors extends api.Mirrors {
override def isEffectiveRoot = true
override def isStatic = true
override def isNestedClass = false
override def ownerOfNewSymbols = EmptyPackageClass
}
// The empty package, which holds all top level types without given packages.
final object EmptyPackage extends ModuleSymbol(RootClass, NoPosition, nme.EMPTY_PACKAGE_NAME) with WellKnownSymbol {
Expand Down
5 changes: 0 additions & 5 deletions src/reflect/scala/reflect/internal/Symbols.scala
Expand Up @@ -813,11 +813,6 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
*/
def isEffectiveRoot = false

/** For RootClass, this is EmptyPackageClass. For all other symbols,
* the symbol itself.
*/
def ownerOfNewSymbols = this

final def isLazyAccessor = isLazy && lazyAccessor != NoSymbol
final def isOverridableMember = !(isClass || isEffectivelyFinal) && (this ne NoSymbol) && owner.isClass

Expand Down

0 comments on commit 4f3c92e

Please sign in to comment.