aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-18 14:59:56 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-18 15:00:08 +0100
commit559d25c88b39b7f2cac4a6c5b8431f8e0a62b56b (patch)
tree839dfe9e03c7d62d5a9c8d01f12fbc80ab12f6b8 /src/dotty/tools/dotc/typer/Namer.scala
parenta0d6eedeb64d45af53a3cb93ab48b22855e3a61c (diff)
downloaddotty-559d25c88b39b7f2cac4a6c5b8431f8e0a62b56b.tar.gz
dotty-559d25c88b39b7f2cac4a6c5b8431f8e0a62b56b.tar.bz2
dotty-559d25c88b39b7f2cac4a6c5b8431f8e0a62b56b.zip
Invalidate companions of source-defined symbols
Without such invalidation, the previous classfile loader stays active, which will lead to confusion later on.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 952c7997e..ece9f51a7 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -265,6 +265,26 @@ class Namer { typer: Typer =>
localCtx
}
+ /** `stat` is a definition in package `pkg`. If `stat` has a potential companion,
+ * invalidate the companion symbol by setting its info to NoType. (If the companion
+ * does in fact exist it the info will be immediately reset to a completer
+ * by the subsequent index operation).
+ */
+ private def invalidateCompanion(pkg: Symbol, stat: untpd.Tree)(implicit ctx: Context) = {
+ def invalidate(name: Name) =
+ pkg.info.decl(name).alternatives foreach { member =>
+ if (member.symbol.isClass && !(member.symbol is Package))
+ member.symbol.info = NoType
+ }
+ stat match {
+ case stat: TypeDef if stat.isClassDef =>
+ invalidate(stat.name.moduleClassName)
+ case stat: ModuleDef =>
+ invalidate(stat.name.toTypeName)
+ case _ =>
+ }
+ }
+
/** Expand tree and create top-level symbols for statement and enter them into symbol table */
def index(stat: Tree)(implicit ctx: Context): Context = {
expand(stat)
@@ -277,6 +297,7 @@ class Namer { typer: Typer =>
def indexExpanded(stat: Tree)(implicit ctx: Context): Context = expanded(stat) match {
case pcl: PackageDef =>
val pkg = createPackageSymbol(pcl.pid)
+ pcl.stats foreach (invalidateCompanion(pkg, _))
index(pcl.stats)(ctx.fresh.withOwner(pkg.moduleClass))
ctx
case imp: Import =>