aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-02 10:14:18 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-02 10:14:30 +0100
commit72e1e896d369a3872c49c26544d53f6e04436217 (patch)
tree13d527e686e0d0fc9063639bdf8b0fa5c23f0468 /src
parent4907eb9e16597f1fce246555a45635c496b36264 (diff)
downloaddotty-72e1e896d369a3872c49c26544d53f6e04436217.tar.gz
dotty-72e1e896d369a3872c49c26544d53f6e04436217.tar.bz2
dotty-72e1e896d369a3872c49c26544d53f6e04436217.zip
Ensuring that contexts do not have NoSymbol as owner.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala6
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index ac0e243ff..816216a98 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -276,6 +276,10 @@ object Contexts {
final def addMode(mode: Mode): Context = withMode(this.mode | mode)
final def maskMode(mode: Mode): Context = withMode(this.mode & mode)
final def retractMode(mode: Mode): Context = withMode(this.mode &~ mode)
+
+ override def toString =
+ "Context(\n" +
+ (outersIterator map ( ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}") mkString "\n")
}
/** A condensed context provides only a small memory footprint over
@@ -296,7 +300,7 @@ object Contexts {
def withNewTyperState: this.type = withTyperState(typerState.fresh(isCommittable = true))
def withExploreTyperState: this.type = withTyperState(typerState.fresh(isCommittable = false))
def withPrinterFn(printer: Context => Printer): this.type = { this.printerFn = printer; this }
- def withOwner(owner: Symbol): this.type = { this.owner = owner; this }
+ def withOwner(owner: Symbol): this.type = { assert(owner != NoSymbol); this.owner = owner; this }
def withSettings(sstate: SettingsState): this.type = { this.sstate = sstate; this }
def withCompilationUnit(compilationUnit: CompilationUnit): this.type = { this.compilationUnit = compilationUnit; this }
def withTree(tree: Tree[_ >: Untyped]): this.type = { this.tree = tree; this }
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 43266163b..8486c29df 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -121,7 +121,7 @@ class Typer extends Namer with Applications with Implicits {
case _ =>
i"none of the overloaded alternatives named $name"
}
- val where = if (ctx.owner.exists) s" from ${ctx.owner.enclosingClass}" else ""
+ val where = if (ctx.owner.exists) s" from ${ctx.owner.enclosingClass}" else ""
val whyNot = new StringBuffer
val addendum =
alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot))
@@ -884,7 +884,7 @@ class Typer extends Namer with Applications with Implicits {
ctx.error(i"$pkg is not a packge", tree.pos)
ctx
}
- val stats1 = typedStats(tree.stats, NoSymbol)(packageContext)
+ val stats1 = typedStats(tree.stats, pkg)(packageContext)
cpy.PackageDef(tree, pid1.asInstanceOf[RefTree], stats1) withType pkg.valRef
}
@@ -906,7 +906,7 @@ class Typer extends Namer with Applications with Implicits {
case tree: untpd.Bind => typedBind(tree, pt)
case tree: untpd.ValDef =>
if (tree.isEmpty) tpd.EmptyValDef
- else typedValDef(tree, sym)(localContext.withNewScope)
+ else typedValDef(tree, sym)(ctx.fresh.withTree(tree).withNewScope)
case tree: untpd.DefDef =>
val typer1 = nestedTyper.remove(sym).get
typer1.typedDefDef(tree, sym)(localContext.withTyper(typer1))