diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-19 16:19:03 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-19 16:19:03 +0200 |
commit | 62131749d08657a0103c922c626a0b918cf385b5 (patch) | |
tree | e8c49a9bb6eb41f3f5d4e3ca7e75a431a25c33b9 /src/dotty/tools/dotc/typer/Typer.scala | |
parent | edb9facac55f61540e0f9af8d06ac9390830fcb8 (diff) | |
download | dotty-62131749d08657a0103c922c626a0b918cf385b5.tar.gz dotty-62131749d08657a0103c922c626a0b918cf385b5.tar.bz2 dotty-62131749d08657a0103c922c626a0b918cf385b5.zip |
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) <init> 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`.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 13 |
1 files changed, 6 insertions, 7 deletions
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 => |