diff options
author | Martin Odersky <odersky@gmail.com> | 2014-04-03 17:57:23 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-04-08 16:56:18 +0200 |
commit | 3486eb0088f78e8ca93c0bc8f883c2af53ee7d3d (patch) | |
tree | dabec550963a84d9f6c72feb800117661aab6e36 /src | |
parent | 879a0b25f2129a1f723953f3cd8f8c82d8ff7f62 (diff) | |
download | dotty-3486eb0088f78e8ca93c0bc8f883c2af53ee7d3d.tar.gz dotty-3486eb0088f78e8ca93c0bc8f883c2af53ee7d3d.tar.bz2 dotty-3486eb0088f78e8ca93c0bc8f883c2af53ee7d3d.zip |
Avoid creating a local dummy when retyping.
Retyping should not create new symbols and that includes local dummys.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/ReTyper.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala index 896dbba7d..c2f627b1e 100644 --- a/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/src/dotty/tools/dotc/typer/ReTyper.scala @@ -3,7 +3,7 @@ package typer import core.Contexts._ import core.Types._ -import core.Symbols.Symbol +import core.Symbols._ import typer.ProtoTypes._ import ast.{tpd, untpd} import ast.Trees._ @@ -48,6 +48,8 @@ class ReTyper extends Typer { untpd.cpy.Bind(tree, tree.name, body1).withType(tree.typeOpt) } + override def localDummy(cls: ClassSymbol, impl: untpd.Template)(implicit ctx: Context) = impl.symbol + override def retrieveSym(tree: untpd.Tree)(implicit ctx: Context): Symbol = tree.symbol override def localTyper(sym: Symbol) = this diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 60acda4b7..6e613975b 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -809,11 +809,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val parents1 = ensureConstrCall(ensureFirstIsClass( parents mapconserve typedParent, cdef.pos.toSynthetic)) val self1 = typed(self)(ctx.outer).asInstanceOf[ValDef] // outer context where class memebers are not visible - val localDummy = ctx.newLocalDummy(cls, impl.pos) - val body1 = typedStats(body, localDummy)(inClassContext(self1.symbol)) + val dummy = localDummy(cls, impl) + val body1 = typedStats(body, dummy)(inClassContext(self1.symbol)) checkNoDoubleDefs(cls) val impl1 = cpy.Template(impl, constr1, parents1, self1, body1) - .withType(localDummy.termRef) + .withType(dummy.termRef) assignType(cpy.TypeDef(cdef, mods1, name, impl1), cls) // todo later: check that @@ -825,6 +825,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit // 4. Polymorphic type defs override nothing. } + def localDummy(cls: ClassSymbol, impl: untpd.Template)(implicit ctx: Context): Symbol = + ctx.newLocalDummy(cls, impl.pos) + def typedImport(imp: untpd.Import, sym: Symbol)(implicit ctx: Context): Import = track("typedImport") { val expr1 = typedExpr(imp.expr, AnySelectionProto) checkStable(expr1.tpe, imp.expr.pos) |