From 62131749d08657a0103c922c626a0b918cf385b5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 19 Aug 2013 16:19:03 +0200 Subject: Several fixes and refactorings for typechecking 1) Refactoring of package loaders that ensures that a package is always loaded before new members are entered. This led to a refactoring of sourceModule in completers into its own trait 2) Refactoring of optSelfType ot selfInfo. Class Infos may now have a reference to a symbol in their selfInfo field, instead of always a type, as it was before. This allows to introduce laziness for self type evaluation. Laziness is needed so that modules can be desugared and the desugared version be compiled without special tricks. 3) and $init members are no longer inherited. 4) Refactoring of createSymbol and enterSym, so that creating symbols and entering them in a scope is decoupled. Renamed the driver operation form `enterSym(s)` to `index`. --- src/dotty/tools/dotc/typer/Typer.scala | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 6a36eaaa5..7f2ba2959 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -430,7 +430,7 @@ class Typer extends Namer with Applications with Implicits { } def typedBlock(tree: untpd.Block, pt: Type)(implicit ctx: Context) = { - val exprCtx = enterSyms(tree.stats) + val exprCtx = index(tree.stats) val stats1 = typedStats(tree.stats, ctx.owner) val expr1 = typedExpr(tree.expr, pt)(exprCtx) val result = cpy.Block(tree, stats1, expr1).withType(blockType(stats1, expr1.tpe)) @@ -632,8 +632,7 @@ class Typer extends Namer with Applications with Implicits { def typedRefinedTypeTree(tree: untpd.RefinedTypeTree)(implicit ctx: Context): RefinedTypeTree = { val tpt1 = typedAheadType(tree.tpt) val refineClsDef = desugar.refinedTypeToClass(tree) - val throwAwayScopeCtx = ctx.fresh.withNewScope - val refineCls = createSymbol(refineClsDef)(throwAwayScopeCtx).asClass + val refineCls = createSymbol(refineClsDef).asClass val TypeDef(_, _, Template(_, _, _, refinements1)) = typed(refineClsDef) assert(tree.refinements.length == refinements1.length, s"${tree.refinements} != $refinements1") def addRefinement(parent: Type, refinement: Tree): Type = { @@ -721,11 +720,9 @@ class Typer extends Namer with Applications with Implicits { val mods1 = typedModifiers(mods) val constr1 = typed(constr).asInstanceOf[DefDef] val parents1 = parents mapconserve (typed(_)) - val self1 = cpy.ValDef(self, typedModifiers(self.mods), self.name, typedType(self.tpt), EmptyTree) - .withType(NoType) - + val self1 = typed(self).asInstanceOf[ValDef] val localDummy = ctx.newLocalDummy(cls, impl.pos) - val body1 = typedStats(body, localDummy)(inClassContext(cls, self.name)) + val body1 = typedStats(body, localDummy)(inClassContext(self1.symbol)) val impl1 = cpy.Template(impl, constr1, parents1, self1, body1) .withType(localDummy.symRef) @@ -931,6 +928,8 @@ class Typer extends Namer with Applications with Implicits { */ def adapt(tree: Tree, pt: Type)(implicit ctx: Context): Tree = { + println(i"adapting $tree of type ${tree.tpe} to $pt") + def adaptOverloaded(ref: TermRef) = { val altDenots = ref.denot.alternatives val alts = altDenots map (alt => -- cgit v1.2.3