From 4f3c92e0f8f8c8017a0363836324089f07d05c4c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 18 Jul 2012 23:11:13 +0200 Subject: SI-5939 resident compilation of sources in empty package Empty packages can now be cleanly invalidated. --- .../scala/tools/nsc/symtab/SymbolLoaders.scala | 21 +++++++++++---------- src/reflect/scala/reflect/internal/Mirrors.scala | 3 +-- src/reflect/scala/reflect/internal/Symbols.scala | 5 ----- 3 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 0c988ceae4..9b4e793241 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -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) @@ -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 @@ -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) } } diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index 210af661ee..761b993539 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -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) @@ -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 { diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index fab5c5a2e7..d484617767 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -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 -- cgit v1.2.3