aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-04 08:35:42 +0200
committerMartin Odersky <odersky@gmail.com>2014-09-04 08:41:01 +0200
commit225102627d37f16134bc682eb5b01270684a02e4 (patch)
tree6a57d22adc7c8231b7fbfcc22832ab68a698cb95 /src/dotty/tools/dotc/typer/Namer.scala
parent2558c49984611935fff91b0b062f6af5a61e71ce (diff)
downloaddotty-225102627d37f16134bc682eb5b01270684a02e4.tar.gz
dotty-225102627d37f16134bc682eb5b01270684a02e4.tar.bz2
dotty-225102627d37f16134bc682eb5b01270684a02e4.zip
Add inSuperCall mode and flag.
Needed to keep a record of definitions in supercall arguments. These may not see the enclosing class.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 782faf0d4..5ceab475e 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -200,7 +200,7 @@ class Namer { typer: Typer =>
}
else completer
- typr.println(i"creating symbol for $tree")
+ typr.println(i"creating symbol for $tree in ${ctx.mode}")
def checkNoConflict(name: Name): Unit = {
def preExisting = ctx.effectiveScope.lookup(name)
@@ -213,12 +213,13 @@ class Namer { typer: Typer =>
}
}
+ val inSuperCall = if (ctx.mode is Mode.InSuperCall) InSuperCall else EmptyFlags
tree match {
case tree: TypeDef if tree.isClassDef =>
val name = tree.name.encode.asTypeName
checkNoConflict(name)
val cls = record(ctx.newClassSymbol(
- ctx.owner, name, tree.mods.flags,
+ ctx.owner, name, tree.mods.flags | inSuperCall,
cls => adjustIfModule(new ClassCompleter(cls, tree)(ctx), tree),
privateWithinClass(tree.mods), tree.pos, ctx.source.file))
cls.completer.asInstanceOf[ClassCompleter].init()
@@ -229,6 +230,8 @@ class Namer { typer: Typer =>
val isDeferred = lacksDefinition(tree)
val deferred = if (isDeferred) Deferred else EmptyFlags
val method = if (tree.isInstanceOf[DefDef]) Method else EmptyFlags
+ val inSuperCall1 = if (tree.mods is ParamOrAccessor) EmptyFlags else inSuperCall
+ // suppress inSuperCall for constructor parameters
val higherKinded = tree match {
case tree: TypeDef if tree.tparams.nonEmpty && isDeferred => HigherKinded
case _ => EmptyFlags
@@ -243,7 +246,7 @@ class Namer { typer: Typer =>
val cctx = if (tree.name == nme.CONSTRUCTOR) ctx.outer else ctx
record(ctx.newSymbol(
- ctx.owner, name, tree.mods.flags | deferred | method | higherKinded,
+ ctx.owner, name, tree.mods.flags | deferred | method | higherKinded | inSuperCall1,
adjustIfModule(new Completer(tree)(cctx), tree),
privateWithinClass(tree.mods), tree.pos))
case tree: Import =>
@@ -428,7 +431,7 @@ class Namer { typer: Typer =>
class ClassCompleter(cls: ClassSymbol, original: TypeDef)(ictx: Context) extends Completer(original)(ictx) {
withDecls(newScope)
- protected implicit val ctx: Context = localContext(cls)
+ protected implicit val ctx: Context = localContext(cls).setMode(ictx.mode &~ Mode.InSuperCall)
val TypeDef(_, name, impl @ Template(constr, parents, self, body)) = original