aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-23 18:31:21 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-23 18:31:21 +0100
commitb9b5e970f8c56d490101156c4fe849c1e952e490 (patch)
treea7b1e72c39c58517f8c90c6a68752dfbcba313a2 /src/dotty/tools/dotc/typer/Namer.scala
parentdbe6ad9dcd9fed37ce2ed63ac7c5403eeb056ae4 (diff)
downloaddotty-b9b5e970f8c56d490101156c4fe849c1e952e490.tar.gz
dotty-b9b5e970f8c56d490101156c4fe849c1e952e490.tar.bz2
dotty-b9b5e970f8c56d490101156c4fe849c1e952e490.zip
Early indexing of parameters in classes.
Type parameters of classes have to be entered before the class is completed.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 18005c596..2baa3ea13 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -177,10 +177,12 @@ class Namer { typer: Typer =>
println(i"creating symbol for $tree")
tree match {
case tree: TypeDef if tree.isClassDef =>
- record(ctx.newClassSymbol(
+ val cls = record(ctx.newClassSymbol(
ctx.owner, tree.name.encode.asTypeName, tree.mods.flags,
- cls => adjustIfModule(new ClassCompleter(cls, tree)(ctx) withDecls newScope, tree),
+ cls => adjustIfModule(new ClassCompleter(cls, tree)(ctx), tree),
privateWithinClass(tree.mods), tree.pos, ctx.source.file))
+ cls.completer.asInstanceOf[ClassCompleter].init()
+ cls
case tree: MemberDef =>
val deferred = if (lacksDefinition(tree)) Deferred else EmptyFlags
val method = if (tree.isInstanceOf[DefDef]) Method else EmptyFlags
@@ -336,9 +338,20 @@ class Namer { typer: Typer =>
}
class ClassCompleter(cls: ClassSymbol, original: TypeDef)(ictx: Context) extends Completer(original)(ictx) {
+ withDecls(newScope)
protected implicit val ctx = localContext(cls)
+ val TypeDef(_, name, impl @ Template(constr, parents, self, body)) = original
+
+ val (params, rest) = body span {
+ case td: TypeDef => td.mods is Param
+ case td: ValDef => td.mods is ParamAccessor
+ case _ => false
+ }
+
+ def init() = index(params)
+
/** The type signature of a ClassDef with given symbol */
override def complete(denot: SymDenotation): Unit = {
@@ -357,14 +370,6 @@ class Namer { typer: Typer =>
else typedAheadExpr(constr).tpe
}
- val TypeDef(_, name, impl @ Template(constr, parents, self, body)) = original
-
- val (params, rest) = body span {
- case td: TypeDef => td.mods is Param
- case td: ValDef => td.mods is ParamAccessor
- case _ => false
- }
- index(params)
val selfInfo =
if (self.isEmpty) NoType
else if (cls is Module) cls.owner.thisType select sourceModule