From 3486eb0088f78e8ca93c0bc8f883c2af53ee7d3d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 3 Apr 2014 17:57:23 +0200 Subject: Avoid creating a local dummy when retyping. Retyping should not create new symbols and that includes local dummys. --- src/dotty/tools/dotc/typer/Typer.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 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) -- cgit v1.2.3